当使用psycopg2库的connect
方法时,我很困惑为什么会出现这样的错误:该方法接受“0个位置参数,但给出了1个。”以下代码的两个变体都产生了错误:
psycopg2.connect("dbname=daniellee host=localhost")
psycopg2.connect("dbname='daniellee' host='localhost'")
回溯如下:
TypeError Traceback (most recent call last) in () ----> 1 psycopg2.connect("dbname='daniellee' host='localhost'")
TypeError: connect() takes 0 positional arguments but 1 was given
我还尝试了传入一组变量和值,如下所示,这产生了一个错误,声明,“意外的关键字参数‘dbname’。”
^{pr2}$这些错误都没有意义,因为这些代码片段遵循psycopg2文档中概述的语法。我已经试着让它工作了几个小时,但都没用。任何帮助都将不胜感激。在
目前没有回答
相关问题 更多 >
编程相关推荐