-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql2.py
More file actions
28 lines (26 loc) · 1.03 KB
/
sql2.py
File metadata and controls
28 lines (26 loc) · 1.03 KB
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
import mysql.connector
from _ctypes import buffer_info
my=mysql.connector.connect(user="root",
host="localhost",
password="root")
print(my)
cursor=my.cursor(buffered=True)
#cursor.execute("create database nidhi")
cursor.execute("use nidhi")
# cursor.execute("CREATE table persons(personid int NOT NULL AUTO_INCREMENT,LastName varchar(255),FirstName varchar(255),Age int(255),PRIMARY KEY (Personid))")
#cursor.execute("insert into persons values(1,'gupta','ram',20)")
# my.commit()
# #cursor.execute("insert into persons values(null,'kapoor','vijay',20)")
# my.commit()
# insert_query="insert into persons value(null,%s,%s,%s)"
# data=[('khayap','shivani',21),('jain','nidhi',20),('goyal','shivani',20)]
# cursor.executemany(insert_query,data)
# my.commit()
cursor.execute("use nidhi")
cursor.execute("select * from persons")
print(cursor.fetchone())
print(cursor.fetchone())
print(cursor.fetchall())
print(cursor.fetchone())
# for record in cursor in cursor.fetchall():
# print("record found",