0

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'

1 Answer 1

1

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 * ...")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.