sqlmodel/docs_src/tutorial/code_structure/tutorial002/database.py
2021-08-24 14:50:16 +02:00

11 lines
231 B
Python

from sqlmodel import SQLModel, create_engine
sqlite_file_name = "database.db"
sqlite_url = f"sqlite:///{sqlite_file_name}"
engine = create_engine(sqlite_url)
def create_db_and_tables():
SQLModel.metadata.create_all(engine)