I am using this posgres , python with cursor. This is my code
class User():
def __init__(self, config):
self.con = psycopg2.connect(**config)
self.cursor = self.con.cursor
def getListS(self):
from pprint import pprint
cursor = self.cursor
cursor.execute("bla bla")
I am getting this error
AttributeError: 'builtin_function_or_method' object has no attribute 'execute'
This is because self.con.cursor
is a method, and should be called in order to get the cursor
object.
In the getListS
method do:
cursor = self.cursor()
cursor.execute("select * ...")