Python调用mysql更新数据的方法


当前第2页 返回上一页

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

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

# encoding: utf-8

import time

import sys

reload(sys)

sys.setdefaultencoding('utf-8')

time1 = time.time()

import pandas as pd

import pymysql

############################################从数据库读数据###########################################

###########线上######################

# 加上字符集参数,防止中文乱码

# conn=pymysql.connect(

#  host="##########",

#  database="######",

#  user="####",

#  password="##########",

#  port=#######,

#  charset='utf8'

# )

# #############测试库######################

# ## 加上字符集参数,防止中文乱码

# conn=pymysql.connect(

#  host="172.16.34.32",

#  database="#########",

#  user="admin",

#  password="##############",

#  port=#########,

#  charset='utf8'

# )

#sql语句(安徽)

# sqlcmd="""

# SELECT order_no from t_order_info WHERE offline_org_no in(

# 0032,0035,0036

#

#

# ) and substr(create_time,1,10)>="2017-10-31"

#

# and `status` in(105,106,107,108)

#

# and manage_cost_rate=0.052

#

#

# """

#################sql语句(江苏)

# sqlcmd2="""

# SELECT order_no from t_order_info WHERE offline_org_no in(

# 0002,0005,0006,0007,0008,0009,0010,0011,0012,0013,0014,0017,0018,0019,0025,0026,0027,0028,0030,0031,0033,0034

# ) and substr(create_time,1,10)>="2017-10-31"

# and `status` in(105,106,107,108)

# and manage_cost_rate=0.052

#

# """

#利用pandas 模块导入mysql数据

# data=pd.read_sql(sqlcmd2,conn)

# print data

#

#

# ###################更新order_rapay表

# for each in data["order_no"]:

#   print each

#   # 创建游标

#   cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)

#   #有参数存储过程

#   cursor.execute('call update_t_order_rapay(%s)',(each))

#   conn.commit()

#

# print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

# #####################更新order_info表###################

# for each in data["order_no"]:

#   print each

#

#   # 创建游标

#   cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)

#   #有参数存储过程

#   cursor.execute('call update_t_order_info(%s)', (each))

#   conn.commit()

#

#

# cursor.close()

# print '调用存储过程完毕................'

# conn.close()

# time2=time.time()

# print u'总共耗时:' + str(time2 - time1) + 's'

相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

推荐阅读:

diff的对象是虚拟dom

Event emitter的监听事件

以上就是Python调用mysql更新数据的方法的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

Python中defaultdict与lambda表达式用法

什么是Python re.compile 函数?

Python基础学完后再学什么

Python怎么模拟点击网页按钮

Python能做什么科学计算

关于Python中布局操作以及模块结构的详解

Python中flask应用(表单处理)

Python如何做一个登录注册界面

Python中怎样把矩阵转换为列表

Python excel使用xlutils类库实现追加写功能的方法

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...