Skip to content

Commit

Permalink
Get Row note data
Browse files Browse the repository at this point in the history
  • Loading branch information
yu23ki14 authored and osoken committed May 30, 2024
1 parent e7bea9f commit 866f771
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions etl/src/birdxplorer_etl/lib/sqlite/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
from sqlalchemy.orm import sessionmaker
import os
from prefect import get_run_logger
from birdxplorer_common.storage import Row
from birdxplorer_common.storage import RowNoteRecord
from sqlalchemy import inspect

def init_db():
logger = get_run_logger()

# ToDo: dbファイルをS3など外部に置く必要がある。
db_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'data', 'note.db'))
logger.info(f'Initializing database at {db_path}')
engine = create_engine('sqlite:///' + db_path)
Base.metadata.create_all(engine)

# 一時データベースのテーブル作成する
# ToDo: noteテーブル以外に必要なものを追加
if not inspect(engine).has_table('note'):
logger.info('Creating table note')
RowNoteRecord.metadata.create_all(engine)

Session = sessionmaker(bind=engine)

return Session()

0 comments on commit 866f771

Please sign in to comment.