sqlmodel/docs_src/tutorial/code_structure/tutorial001/database.py

11 lines
231 B
Python
Raw Normal View History

2021-08-24 12:50:16 +00:00
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)