aiomysql inserting operation failed !
emotions:
those days,i am using aiomysql(python3.5) to acess my database .But a 'strange' problem make me trouble more times.The problem is i can't insert data into my database table using aiomysql's cursor.execute(**) method. Fortunately,i sovled it after refering aiomysq's manual.
plateform:
1.ubuntu14.04
2.python3.5
error code:
import aiomysql
import asyncio
loop=asyncio.get_event_loop()
@asyncio.coroutine
def insert(loop):
pl=yield from aiomysql.create_pool(host='127.0.0.1',user='root',password='xxxxx',db='blog',loop=loop,port=3306)
with (yield from pl) as con:
cursor=yield from con.cursor()
yield from cursor.execute('insert into users(`user_name`,`email`,`password`) values("coder","1xxxxxb@gmail.com","FHEUIE@#@@##JNDJA")')
yield from cursor.close()
con.commit()
pl.close()
yield from pl.wait_closed()
loop.run_until_complete(insert(loop))
loop.run_forever()
I run the above code many times,but there is still no data in my database table.
solution:
After refering aiomysql's manual,I found 'aiomysql.commit' method is coroutine,that's a critical point.just rewrite 'con.commit()' to 'yield from con.commit()',the problem is sovled!
correct code:
import aiomysql
import asyncio
loop=asyncio.get_event_loop()
@asyncio.coroutine
def insert(loop):
pl=yield from aiomysql.create_pool(host='127.0.0.1',user='root',password='xxxxx',db='blog',loop=loop,port=3306)
with (yield from pl) as con:
cursor=yield from con.cursor()
yield from cursor.execute('insert into users(`user_name`,`email`,`password`) values("coder","1xxxxxb@gmail.com","FHEUIE@#@@##JNDJA")')
yield from cursor.close()
yield from con.commit()
pl.close()
yield from pl.wait_closed()
loop.run_until_complete(insert(loop))
loop.run_forever()
aiomysql inserting operation failed !的更多相关文章
- 安装 composer SSL operation failed with code 1
gavin@webdev:~> curl -sS https://getcomposer.org/installer | php Downloading... Download failed: ...
- vsftp关于"550 create directory operation failed"问题解决
前提: 昨天晚上配置好了vsftp, 但登陆后,除了浏览,什么也干不了.(如新建文件/文件夹, 删除文件, 重命名等都不可操作) 都是弹出 "550 create directory ope ...
- Error: ORA-16501: the Data Guard broker operation failed ORA-16625: cannot reach database
在备库上建配置文件 DGMGRL> create configuration 'sharkdbbork' as primary database is 'sharkdb' connect ide ...
- 550 Create directory operation failed
往Linux系统中上传文件时候,我们经常会使用FTP连接Linux,也经常会使用mkdir命令来创建目录.最近发现用mkdir创建目录时提示550 Create directory operation ...
- Linux虚拟主机通过FTP软件创建目录时提示550 Create Directory Operation Failed
更新时间:2017-06-07 13:26:11 分享: 问题描述 通过FTP软件连接Linux虚拟主机,在尝试创建新目录时,服务器返回错误提示:550 Create Directory Oper ...
- composer在update时提示file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO
在开发的时候,需要把依赖的服务更新到最新,然后 手动composer update一下,提示如下: failed) Update failed (The "e "https://a ...
- xcode9上传app时报错iTunes Store operation failed 解决方案
问题 上传至itunes Connect时报了两个错: iTunes Store Operation Failed ERROR ITMS-xxxxx:"description length: ...
- 使用PHPMailer 中的报错解决 "Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:"
PHPMailer项目地址:https://github.com/PHPMailer/PHPMailer 项目中用到PHPMailer,使用过程中报错:"Connection failed. ...
- ftp删除目录和文件,目录下有文件删除提示【550 Remove directory operation failed.】
注意:目录下有文件,直接删除目录会失败,提示550 Remove directory operation failed. 必须先将目录下的文件都删除,才能删除目录 ftp命令行: ftp删除目 ...
随机推荐
- android studio项目提交Git@OSC
转载地址:http://www.bubuko.com/infodetail-977061.html 先到git.oscchina.net网站上申请个账号,然后创建一个项目.过程不再说了. 新建工程后, ...
- ArcGIS Server 10.1发布GP服务
ArcGIS Server 10.1发布GP服务 ArcGIS Server 10.1发布GP服务确实更简单了,只是刚使用不怎么习惯.ArcGIS Server 10.1发布GP服务需要先在ArcCa ...
- Servlet详解之两个init方法的作用
在Servlet中 javax.servlet.GenericServlet类 继承自java.lang.Object 实现了Serializable,,servlet ,ServletConfig ...
- asterisk-java ami2 事件监听
asteriskServer文章1提到啦怎么获取,就不解释 asteriskServer.addChainListener(new AsteriskeventListenerInit());//整个服 ...
- 轮播插件unslider.min.js使用demo
有两种应用方式: 1.轮播图片作为<img>标签使用 HTML代码: <html> <head> <meta charset="utf-8" ...
- js字符串、数组、时间、日期对象
js对字符串.数组.日期的操作是在以后项目中频繁使用的操作,所以呢....所以大家看着办,其实并不难哈,就是有点无聊,我承认这是我百度的,哈哈哈哈 <!DOCTYPE html><h ...
- 洛谷 P3119 [USACO15JAN]草鉴定Grass Cownoisseur
屠龙宝刀点击就送 Tarjan缩点+拓扑排序 以后缩点后建图看n范围用vector ,或者直接用map+vector 结构体里数据要清空 代码: #include <cstring> #i ...
- redis的一些问题总结,转载自infoq
Redis是时下比较流行的Nosql技术.在优酷我们使用Redis Cluster构建了一套内存存储系统,项目代号蓝鲸.到目前为止集群有700+节点,即将达到作者推荐的最大集群规模1000节点.集群从 ...
- 剑指offer18 树的子结构
另一种写法 class Solution { public: bool HasSubtree(TreeNode* pRoot1, TreeNode* pRoot2) { bool result = f ...
- java中异常处理机制 throw抛出自定义业务逻辑异常 throws继续抛出 catch捕获后会自动继续抛向调用方法
package com.swift; public class Exception_TestC { public static void main(String[] args) { /* * 第5题: ...