-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudents2.py
43 lines (28 loc) · 1.01 KB
/
students2.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
import mysql.connector
print("Content-Type: text/html;charset=utf-8")
print()
##create a connection to the database
con = mysql.connector.connect(host='localhost',database='studentw',user ='root',password='12345Trial1@')
#create a cursor#
cur = con.cursor()
#create insert statement
sql = "INSERT INTO EMPLOYEERED(FIRST_NAME,LAST_NAME,AGE,SEX,INCOME)"\
"VALUES ('Mamiliaa','Johns','28','M', 7000)"\
sql = "INSERT INTO EMPLOYEEZ(FIRST_NAME,LAST_NAME,AGE,SEX,INCOME)"\
"VALUES ('Justus','Reagan','25','M', 4000)"\
sql = "INSERT INTO EMPLOYEED(FIRST_NAME,LAST_NAME,AGE,SEX,INCOME)"\
"VALUES ('Joseph','Right','32','M', 3800)"\
#execute query
cur.execute(sql)
con.close()
#print a statement
print('Database inserted Successfully')
import sys
if con.is_connected():
print ('Connected to MySQL database')
cursor.excute(""" SELECT * FROM EMPLOYEERED""")
# fetch all of the rows from the query
data = cur.fetchall ()
# print the rows
for row in data :
print(row[1])