![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
mysql
NoOne-csdn
永远年轻,永远热泪盈眶
展开
-
(已解决)python multiprocess 多进程操作mysql时丢失数据
背景用python multiprocess 开了100个进程写数据库,共享一个链接发现有时候 遗漏数据 不报错lock.acquire()conn.execute(sql)lock.release()当改成单独链接的时候报错Deadlock found when trying to get lock; try restarting transaction...原创 2020-05-27 18:20:13 · 2761 阅读 · 0 评论 -
Mysql 必知必会(持续更新中)
LIMIT X,Y 与 LIMIT x OFFST ylimit语法支持两个参数,offset和limit,前者表示偏移量,后者表示取前limit条数据.## 返回符合条件的前10条语句 select * from user limit 10## 返回符合条件的第11-20条数据select * from user limit 10,20## 为了检索从某一个偏移量到记录集的...原创 2020-03-24 16:18:31 · 283 阅读 · 0 评论 -
gorm mysql JSON精确查询
byt:=[]byte(SearchContent) var dat map[string]interface{} if err := json.Unmarshal(byt, &dat); err != nil { } for k,v:=range dat{ str:="JSON_EXTRACT(content,'$."+k+"')=(?)" db=db....原创 2019-08-27 14:36:09 · 3477 阅读 · 0 评论 -
mysql ON DUPLICATE KEY UPDATE
sql = f'''insert into t_user_question_num (user_id, exam_id, right_num, record_num,update_time,create_time) values'''# print(res)for i in range(len(res)): s = res.loc[i] sql = sql + str(tup...原创 2019-07-04 09:56:04 · 150 阅读 · 0 评论 -
mysql unixtime 直接取日期
with self.duengine.connect() as conn: for i in range(100): sql = "select user_id,duration,subject_1,item_id,Date(from_unixtime(create_time)) as create_time from `t_exer_record_{}` where ...原创 2018-12-01 10:19:05 · 703 阅读 · 0 评论 -
pandas处理后的数据一次性插入mysql 大概20万条 zip 函数
mysql数据表结构如下: 利用pandas处理后的数据格式如下:方法一:with self.tikuengine1.connect() as conn: result.to_sql('t_exam', con=conn, if_exists='replace', chunksize=3000)速度较快,但是每次时追加或者替换,且不能设置主键(待验证)方法...原创 2018-12-04 11:08:59 · 1633 阅读 · 0 评论 -
sqlalchemy.exc.InternalError: ('(pymysql.err.InternalError) (1054, "Unknown column 已经解决
sql = f''' insert into `t_datav`(category,paper_id,title,allcount,joincount,score,paper_create_time) values( "mock",{id},{title},{allcount},{joincount},{score},{create_time})...原创 2018-11-26 14:26:42 · 9866 阅读 · 0 评论 -
sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError)
源代码:sql = """ UPDATE t_datav SET info ="%s" WHERE category ="mock" """ % (res)改后:sql=""" UPDATE t_datav SET info ="%s" WHERE category ="原创 2018-11-26 10:20:19 · 6542 阅读 · 0 评论 -
mysql truncate, drop,delete 表的区别
程度从强到弱1、drop table tbdrop将表格直接删除,没有办法找回2、truncate (table) tb删除表中的所有数据,不能与where一起使用添加新的数据时ID从1开始自增3、delete from tb (where)删除表中的数据(可制定某一行)添加新数据时ID从删除之前的最后一个数自增区别:truncate和delete的区别1、事务:trun...原创 2018-11-22 17:28:01 · 161 阅读 · 1 评论 -
mysql 查询前一周,一个月的数据 unix时间
end = datetime.date.today()start = datetime.date.today() - relativedelta(months=+1) sql = f''' select user_id,duration,subject_1,item_id,channel,from_unixtime(create_time) as create_time from `t_ex...原创 2018-11-21 19:14:44 · 712 阅读 · 0 评论 -
mysql 查询当天,一周,一月的查询语句
select * from `t_exer_record_88` where DATE_SUB(CURDATE(), INTERVAL 7 DAY)<= date(update_time);select * from `t_exer_record_88` where DATE_SUB(CURDATE(), INTERVAL 1 MONTH )<= date(update_t...原创 2018-11-14 15:59:51 · 526 阅读 · 0 评论