FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gittutorial/python/start_using_sqlite_with_python.py at master · MParsa-ES/gittutorial · GitHub
MParsa-ES
/
gittutorial
Public
forked from
jadijadi/gittutorial
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
gittutorial
/
python
/
start_using_sqlite_with_python.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
18 lines (12 loc) · 637 Bytes
Breadcrumbs
gittutorial
/
python
/
start_using_sqlite_with_python.py
Copy path
File metadata and controls
18 lines (12 loc) · 637 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
import
sqlite3
conn
=
sqlite3
.
connect
(
'database_name.db'
)
# connect to the database or create it if it doesn't exist before
c
=
conn
.
cursor
()
# use this cursor object to run sql commands
#for first run be OK but more not OK. Then add this line for more runs
c
.
execute
(
'''drop table if exists table_name'''
)
c
.
execute
(
'''create table table_name (col_1_name int, col_2_name int)'''
)
# create a table with two columns
c
.
execute
(
'''insert into table_name values (1, 1)'''
)
# insert two records to that table
c
.
execute
(
'''insert into table_name values (2, 2)'''
)
conn
.
commit
()
# commit changes
conn
.
close
()
print
(
'done'
)
print
(
"finish"
)
Back
|
FazBrowse Home
|
New Git URL