FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlmodel/docs_src/tutorial/code_structure/tutorial001/app.py at main · mkarbo/sqlmodel · GitHub
mkarbo
sqlmodel
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlmodel
/
docs_src
/
tutorial
/
code_structure
/
tutorial001
/
app.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (19 loc) · 669 Bytes
Breadcrumbs
sqlmodel
/
docs_src
/
tutorial
/
code_structure
/
tutorial001
/
app.py
Copy path
File metadata and controls
29 lines (19 loc) · 669 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from
sqlmodel
import
Session
from
.
database
import
create_db_and_tables
,
engine
from
.
models
import
Hero
,
Team
def
create_heroes
():
with
Session
(
engine
)
as
session
:
team_z_force
=
Team
(
name
=
"Z-Force"
,
headquarters
=
"Sister Margaret’s Bar"
)
hero_deadpond
=
Hero
(
name
=
"Deadpond"
,
secret_name
=
"Dive Wilson"
,
team
=
team_z_force
)
session
.
add
(
hero_deadpond
)
session
.
commit
()
session
.
refresh
(
hero_deadpond
)
print
(
"Created hero:"
,
hero_deadpond
)
print
(
"Hero's team:"
,
hero_deadpond
.
team
)
def
main
():
create_db_and_tables
()
create_heroes
()
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL