首页 > 代码库 > day38 pymysql

day38 pymysql

技术分享
 1 #! /usr/bin/env python
 2 # -*- coding:utf-8 -*-
 3 import  pymysql
 4 conn = pymysql.connect(host=127.0.0.1, port=3306, user=root, passwd=123, db=t1)
 5 cursor=conn.cursor()
 6 # exc=cursor.execute("update tb1 set user=‘88‘ ")
 7 # exc=cursor.execute("insert into tb1(user,date) VALUES (‘89‘,‘2017-07-20‘)")
 8 # exc=cursor.execute("insert into tb1(user,date) VALUES (%s,%s)",(‘zj‘,‘2017-07-20‘))
 9 # exc=cursor.executemany("insert into tb1(user,date) VALUES (%s,%s)",
10 #                        [(‘zj‘,‘2017-07-20‘),(‘nn‘,‘2017-07-20‘)])
11 
12 # cursor=conn.cursor(cursor=pymysql.cursors.DictCursor)
13 # 把拿到的数据便成字典
14 # effect_row = cursor.execute("select * from tb1")
15 # conn.commit()
16 # ret=cursor.fetchall()
17 # print(ret)
18 # r=cursor.fetchone()
19 # print(r)
20 # cursor.fetchmany(2)
21 # 关闭游标
22 cursor.close()
23 # 关闭连接
24 conn.close()
View Code

 

day38 pymysql