gpt4 book ai didi

mysql - 错误 : function' object has no attribute 'execute'

转载 作者:可可西里 更新时间:2023-11-01 07:58:16 24 4
gpt4 key购买 nike

关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。












想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。

3年前关闭。




Improve this question




使用Python 3.4,Mac OS上的mysql。已经安装了mysql,pymysql,mysqlclient-python

import pymysql
import pymysql.cursors
import _mysql

connection = pymysql.connect(host='localhost',user='sth',password ='', db = 'mydb')
query = "INSERT INTO mydb (card, price,color,index1) VALUES ('cardeeef','3.24','B','frsss')"
cur = connection.cursor
cur.execute(query)
results =cur.fetchall()

不确定还需要什么,所以它知道“.execute”

最佳答案

在 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

关于mysql - 错误 : function' object has no attribute 'execute' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37491843/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com