-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmys.py
38 lines (37 loc) · 1.52 KB
/
mys.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
import mysql.connector
mydb = mysql.connector.connect(
host = "localhost",
user = "root",
passwd = "shyam",
database = "testdb"
)
mycursor = mydb.cursor()
#def create_database():
# mycursor.execute("CREATE TABLE LICENSE (name VARCHAR(255),vehicle_number VARCHAR(255),email_id VARCHAR(255))")
# sqlFormula = "INSERT INTO license (name, vehicle_number, email_id) VALUES (%s, %s, %s)"
#
# riders = [("Nikhil Rathaur","010 K 414","[email protected]"),
# ("Vinayak Patil", "785 K 686", "[email protected]"),
# ("Shyam R","538 E 945" ,"[email protected]"),
# ("Harry Potter", "032 A 163", "[email protected]"),
# ("Rohan Panday", "BJ 7496","[email protected]"),
# ("Shaurya Sinha" , "042 K 729","[email protected]"),
# ("Anubhav Singh", "ZD 45480","[email protected]"),
# ("Yogesh Chandra", "06 5010","[email protected]"),
# ("Lokesh SK","MCLRN F1" , "[email protected]")]
# mycursor.executemany(sqlFormula, riders)
# mydb.commit()
def query(test):
x = test
val = """SELECT email_id FROM license WHERE vehicle_number = %s """
mycursor.execute(val, (x,))
mail = ""
for i in mycursor:
mail += str(i)
mail_add=mail[2:-3]
#print(mail[2:-3])
return mail_add
mycursor.execute("ALTER TABLE license ADD phone_number varchar(15) AFTER email_id")
#if __name__ == '__main__':
# #create_database()
# mail=query("010 K 414")