python连接mysql
2023-09-27 14:25:20 时间
from __future__ import division import pymysql coon = pymysql.connect( host = '',user = 'r',passwd = 'bQ', port =,db = '',charset = '' ) f =file('ddd.txt') i = 0 p_id_dic = {} lists = [] cur = coon.cursor() for line in f: i += 1 chunk = line.strip().split('\t') p_id = chunk[0] price = round(float(chunk[2]) / 1, 2) p_id_dic[int(p_id)] = price lists.append(p_id) if i % 1000: sql = "select p_id, pay_price,total_price from map_ugc_core.task_package where p_id in (%s)" % ','.join(lists) cur.execute(sql) res = cur.fetchall() for db_pid, db_price,total_price in res: if abs(db_price - p_id_dic.get(db_pid)) > 0.01: print db_pid, db_price, p_id_dic.get(db_pid), db_price - p_id_dic.get(db_pid), total_price lists = [] if lists: for db_pid, db_price, total_price in res: if abs(db_price - p_id_dic.get(db_pid)) > 0.01: print db_pid, db_price, p_id_dic.get(db_pid), db_price - p_id_dic.get(db_pid), total_price cur.close() coon.close()
相关文章
- python+ mysql存储二进制流的方式
- Python操作MySQL数据库9个实用实例
- 基于Python的商品展销系统的设计和实现
- 【Raspberry pi+python+mysql】红外传感器-发邮件-存数据库
- Mysql 跨库数据迁移 -- python 脚本
- Python在mysql中进行操作是十分容易和简洁的
- Python操作MySQL数据库的三种方法
- 【Python】连接MySQL数据库(初步测试)
- Python mysql 创建连接
- Python 3.7, Failed building wheel for MySql-Python
- Python 3 and MySQL
- Python +Mysql 安装部署
- PyQt(Python+Qt)学习随笔:QAbstractItemView的showDropIndicator属性
- 流动python - 什么是魔术方法(magic method)
- Python pandas.DataFrame.pct_change函数方法的使用
- Python学多久才能独立接单赚钱?有许多年Python开发经验的我告诉你,一个月就足够了
- 学习数据分析需要多少python基础?
- 用 Python 绘制个人足迹地图
- Python爬虫入门到入职:编写第一个爬虫程序
- C++ 调用python
- python--re模块(正则表达式)
- Python Selenium 之生成BeautifulReport可视化报告
- 十五、python学习之MySQL数据库(二):数据库的操作
- 十八、python学习之MySQL数据库(五):数据库其他高级操作
- python学习之美多商城(四):用户部分--注册业务接口分析、跨域CORS、使用celery异步完成发送短信、