- 论坛徽章:
- 0
|
每周一题。(读写数据库)
我想用python(2.4.1)连postgresql(8.0.3)
我在python中导入pgdb
>;>;>; import pgdb
显示错误
Traceback (most recent call last):
File "<pyshell#5>;", line 1, in -toplevel-
import pgdb
File "D:\Python24\lib\pgdb.py", line 330, in -toplevel-
_connect_ = connect
NameError: name 'connect' is not defined
当我在pgdb.py中注释_connect_ = connect后,可以导入pgdb.py
但是连接数据库时显示
Traceback (most recent call last):
File "<pyshell#7>;", line 1, in -toplevel-
db=pgdb.connect(dsn='localhost racle',user='postgres',password='postgres',host='localhost',database='template1')
File "D:\Python24\lib\pgdb.py", line 375, in connect
cnx = _connect_(dbbase, dbhost, dbport, dbopt,
NameError: global name '_connect_' is not defined
未定义全局变量_connect_,应当如何处理这个问题 |
|