Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python和游标获取属性错误_Python_Postgresql_Cursor - Fatal编程技术网

使用Python和游标获取属性错误

使用Python和游标获取属性错误,python,postgresql,cursor,Python,Postgresql,Cursor,我使用的是posgres,python和游标。这是我的密码 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

我使用的是posgres,python和游标。这是我的密码

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")
我得到了这个错误


AttributeError:“内置函数”或“方法”对象没有属性“执行”

这是因为
self.con.cursor
是一个方法,应该调用它以获取
cursor
对象

getlist
方法中,执行以下操作:

cursor = self.cursor()
cursor.execute("select * ...")