feat: add database setup module
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
041b768cd4
commit
1c4154b84b
@@ -0,0 +1,18 @@
|
|||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
from models import Base
|
||||||
|
|
||||||
|
DB_PATH = "sqlite:///wordsearch.db"
|
||||||
|
|
||||||
|
|
||||||
|
def get_engine(db_url=None):
|
||||||
|
return create_engine(db_url or DB_PATH)
|
||||||
|
|
||||||
|
|
||||||
|
def get_session_factory(engine):
|
||||||
|
return sessionmaker(bind=engine)
|
||||||
|
|
||||||
|
|
||||||
|
def init_db(engine):
|
||||||
|
Base.metadata.create_all(engine)
|
||||||
Reference in New Issue
Block a user