-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestdb.py
More file actions
25 lines (24 loc) · 812 Bytes
/
testdb.py
File metadata and controls
25 lines (24 loc) · 812 Bytes
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
import mariadb
config = {
'user': 'root',
'password': '',
'host': '127.0.0.1', # try changing to localhost
'port': 3306,
'database': 'flask_app',
}
print("Starting Test File...")
conn = mariadb.connect(**config)
cursor = conn.cursor()
# query = f"SELECT customer_id, username FROM Customer WHERE username='charles' AND password='weng';"
# query = f"SELECT patient_id FROM Patient WHERE patient_id='1' AND password='weng';"
query = f"SELECT patient_id, pacemaker_dependent, incision_location, pacemaker_manufacturer, magnet_response, image_path FROM Patient ORDER BY patient_id DESC;"
res = None
try:
conn = mariadb.connect(**config)
cursor = conn.cursor()
cursor.execute(query)
res = cursor.fetchone()
finally:
cursor.close()
conn.close()
print(res[0], res[1])