-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_database.py
44 lines (39 loc) · 1.66 KB
/
test_database.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
import mysql.connector
def td():
try:
conn = mysql.connector.connect(host='localhost', user='root', password='', database='python_database')
cursor = conn.cursor()
cursor.execute('select Name from test where Subject ="AVG TH + PR" && Attendance < 75')
print('\t\tDefaulter:\n')
for i in cursor:
print(i)
conn.close()
except mysql.connector.Error as err:
print('Could not Establish the connection:{}'.format(err))
def td1():
try:
conn = mysql.connector.connect(host='localhost', user='root', password='', database='python_database')
cursor = conn.cursor()
cursor.execute('select Name from test where Subject ="AVG TH + PR" && Attendance < 75')
rows = cursor.fetchall()
return rows
except mysql.connector.Error as err:
print('Could not Establish the connection:{}'.format(err))
def td2():
try:
conn = mysql.connector.connect(host='localhost', user='root', password='', database='python_database')
cursor = conn.cursor()
cursor.execute('select * from test')
rows = cursor.fetchall()
return rows
except mysql.connector.Error as err:
print('Could not Establish the connection:{}'.format(err))
def td3(x):
try:
conn = mysql.connector.connect(host='localhost', user='root', password='', database='python_database')
cursor = conn.cursor()
cursor.execute('select * from test')
rows = cursor.fetchall()
return rows
except mysql.connector.Error as err:
print('Could not Establish the connection:{}'.format(err))