Найти - Пользователи
Полная версия: Cursor.execute
Начало » Python для новичков » Cursor.execute
1
BOB41K
Python 2.5.4

>>> import MySQLdb
>>> db=MySQLdb.connect(host='localhost', user='giga', passwd='xiwo', db='giga')
>>> print(db)
<_mysql.connection open to ‘localhost’ at cd46a0>
>>> cursor=db.cursor
>>> print(cursor)
<bound method Connection.cursor of <_mysql.connection open to ‘localhost’ at cd46a0>>
>>> cursor.execute(“Select * From users”)

Traceback (most recent call last):
File “<pyshell#5>”, line 1, in <module>
cursor.execute(“Select * From users”)
AttributeError: ‘function’ object has no attribute ‘execute’




Что за такая фигня? Куда мог дется “execute”?
Enchantner
BOB41K
забыл скобки после db.cursor, вот у тебя объект и рассматривается ,как ссылка на функцию. исправь db.cursor()
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB