mirror of
https://github.com/fastapi/sqlmodel.git
synced 2025-08-15 02:07:54 +08:00
✨ Add source examples for docs
This commit is contained in:
10
docs_src/tutorial/code_structure/tutorial002/database.py
Normal file
10
docs_src/tutorial/code_structure/tutorial002/database.py
Normal file
@ -0,0 +1,10 @@
|
||||
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)
|
Reference in New Issue
Block a user