Coverage for docs_src/tutorial/create_db_and_table/tutorial001_py310.py: 0%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 00:02 +0000

1from sqlmodel import Field, SQLModel, create_engine 

2 

3 

4class Hero(SQLModel, table=True): 

5 id: int | None = Field(default=None, primary_key=True) 

6 name: str 

7 secret_name: str 

8 age: int | None = None 

9 

10 

11sqlite_file_name = "database.db" 

12sqlite_url = f"sqlite:///{sqlite_file_name}" 

13 

14engine = create_engine(sqlite_url, echo=True) 

15 

16SQLModel.metadata.create_all(engine)