Santosh Reddy
Santosh Reddy

Reputation: 31

error 'long' object has no attribute 'fetchall'

I don't know whats wrong with the attached code, it throws an error error 'long' object has no attribute 'fetchall'. Can some one help me out please.

Code:

enter image description here

Upvotes: 0

Views: 1003

Answers (2)

bruno desthuilliers
bruno desthuilliers

Reputation: 77952

cursor.execute() returns an int telling how many rows where affected (=>selected, inserted, deleted, updated...) by the SQL query, so you cannot chain the .fetchall() call, you need to do it in two steps:

x.execute("your query here")
rows = x.fetchall()

Upvotes: 0

Fejs
Fejs

Reputation: 2888

You should change conn.execute to x.execute.

Upvotes: 1

Related Questions