在Mac OS上使用Python 3.4,mysql。已经安装了mysql,pymysql,mysqlclient-python
des1 = TEMP_FAILURE_RETRY(mq_open(name1, O_RDWR | O_CREAT | O_NONBLOCK, 0666, &attr));
if (des1 < 0)
不确定还需要什么,所以它知道&#34; .execute&#34;
答案 0 :(得分:4)
在Python中,您call functions为()
提供标识符。喜欢这个:
cur = connection.cursor()
这是语法:
call ::= primary "(" [argument_list [","]
| expression genexpr_for] ")"
argument_list ::= positional_arguments ["," keyword_arguments]
["," "*" expression] ["," keyword_arguments]
["," "**" expression]
| keyword_arguments ["," "*" expression]
["," "**" expression]
| "*" expression ["," keyword_arguments] ["," "**" expression]
| "**" expression
positional_arguments ::= expression ("," expression)*
keyword_arguments ::= keyword_item ("," keyword_item)*
keyword_item ::= identifier "=" expression
答案 1 :(得分:1)
您需要将Connection设置为Cursor方法
cur = connection.cursor()
创建时,使用cursor()
方法创建execute()
。 Cursor
只是您将cursor
别名设置为。
你可以写,如果你想:
Cursor = cursor()
cur = connection.Cursor
来自MySQL Cursor Class:
要创建游标,请使用连接对象的cursor()方法:
import mysql.connector
cnx = mysql.connector.connect(database='world')
cursor = cnx.cursor()