/
vendorNum.py
50 lines (36 loc) · 1.14 KB
/
vendorNum.py
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
50
#!/usr/bin/env python
#
# Insert a new element in a MySQLDB1 employee database
# ######################################################
import datetime
import MySQLdb
from pymysqlreplication import BinLogStreamReader
from pymysqlreplication.row_event import *
#MySQLDB1
MySQLdb.connect(host="localhost", port=3306, user="MySQLu1", passwd="I123", db="inventory")
try:
MySQLdb.db_drop('inventory').run()
except:
pass
MySQLdb.db_create('inventory').run()
tables = ['productName', 'storageLocal', 'brandName', 'prices', 'vendor', 'departments']
for table in tables:
MySQLdb.db('inventory').table_create(table).run()
#Get contact number from vendor
ContactNum = cursor.execute("""SELECT name, phone_number
FROM vendor
WHERE name=%s
AND clue > %s
LIMIT 5""",
(name, clue_threshold))
cursor.execute(ContactNum)
def FetchOneAssoc(cursor) :
data = cursor.fetchone()
if data == None :
return None
desc = cursor.description
dict = {}
for (name, value) in zip(desc, data) :
dict[name[0]] = value
return dict
MySQLdb.close()