-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbc_sql.py
More file actions
38 lines (31 loc) · 767 Bytes
/
bc_sql.py
File metadata and controls
38 lines (31 loc) · 767 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
26
27
28
29
30
31
32
33
34
35
36
37
38
import re
import mysql.connector
barcode_db = mysql.connector.connect(
host = "34.80.39.159",
user = "root",
passwd = "team6isbest",
)
# print(barcode_db)
cursor = barcode_db.cursor()
sql_id = "SELECT id FROM `Fiteat`.`Barcode`;"
sql_name = "SELECT food_name FROM `Fiteat`.`Barcode`;"
def food_id():
try:
cursor.execute(sql_id)
results = cursor.fetchall()
for row in results:
#print(row)
return row
except:
print("ID not available")
def food_name():
try:
cursor.execute(sql_name)
results = cursor.fetchall()
for row in results:
#print(row)
return row
except:
print("Food not available")
#food_name()
#food_id()