FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vcs/_4.python/_db/PythonSQL-master/sql-alchemy-ctrl.py at master · bunshue/vcs · GitHub
bunshue
/
vcs
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
3
Code
Issues
0
Pull requests
4
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vcs
/
_4.python
/
_db
/
PythonSQL-master
/
sql-alchemy-ctrl.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (39 loc) · 1.04 KB
Breadcrumbs
vcs
/
_4.python
/
_db
/
PythonSQL-master
/
sql-alchemy-ctrl.py
Copy path
File metadata and controls
49 lines (39 loc) · 1.04 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from
sqlalchemy
import
*
engine
=
create_engine
(
'sqlite:///DevDb.db'
,
echo
=
False
)
conn
=
engine
.
connect
()
db
=
MetaData
()
demo_table
=
Table
(
'demo_table'
,
db
,
Column
(
'id'
,
Integer
,
primary_key
=
True
),
Column
(
'name'
,
String
),
Column
(
'data'
,
String
),
)
appDesc
=
"""
Please input action code :
1 - Insert Data
2 - Update Data
3 - Delect Date
--- --- ---
0 - exit
"""
isRun
=
True
while
(
isRun
):
sql
=
demo_table
.
select
()
result
=
conn
.
execute
(
sql
)
for
row
in
result
:
print
(
row
)
ctrl
=
input
(
appDesc
)
if
ctrl
==
"0"
:
isRun
=
False
elif
ctrl
==
"1"
:
sql
=
demo_table
.
insert
().
values
(
name
=
'App'
,
data
=
"text"
)
conn
.
execute
(
sql
)
elif
ctrl
==
"2"
:
row_id
=
input
(
"row_id = ? "
)
sql
=
demo_table
.
update
().
values
(
name
=
'AppNew'
,
data
=
"new text"
).
where
(
demo_table
.
c
.
id
==
row_id
)
conn
.
execute
(
sql
)
elif
ctrl
==
"3"
:
row_id
=
input
(
"row_id = ?"
)
sql
=
demo_table
.
delete
().
where
(
demo_table
.
c
.
id
==
row_id
)
conn
.
execute
(
sql
)
Back
|
FazBrowse Home
|
New Git URL