嗨我也是python和firebird的新手,我的问题是我正在尝试将我的python程序连接到firebird中的数据库,我已经安装了firebird(目前在/opt/firebird上)我已经创建了我的数据库(测试.fdb)和一张桌子(它在火鸟中工作正常)
create table languages
(
name varchar(20),
year_released integer
);
insert into languages (name, year_released) values ('C', 1972);
insert into languages (name, year_released) values ('Python', 1991);
但是当我试图在 pydev 中运行时会出现问题。
import fdb
con = fdb.connect(dsn="/tmp/test.fdb", user="fernando", password="root")
# Create a Cursor object that operates in the context of Connection con:
cur = con.cursor()
# Execute the SELECT statement:
cur.execute("select * from languages")
# Retrieve all rows as a sequence and print that sequence:
print cur.fetchall()
http://www.firebirdsql.org/file/documentation/drivers_documentation/python/fdb/getting-started.html
数据库的当前位置在 /tmp 上,我正在使用从这里下载的 fdb:https : //pypi.python.org/pypi/fdb/ 并安装了 pip 我也在 pydev properties->pydev pythonpath 中使用并添加了文件夹fdb 的(到目前为止看起来很正常,没有错误),我的用户名是 fernando,密码是 root,所以当我最终运行时,我收到以下错误消息:
Traceback (most recent call last):
File "/home/elfstone/Documents/workspace/NuevosPython/fire.py", line 3, in <module>
con = fdb.connect(dsn="/tmp/test.fdb", user="fernando", password="root")
File "/home/elfstone/Downloads/fdb-1.4/fdb/fbcore.py", line 693, in connect
"Error while connecting to database:")
fdb.fbcore.DatabaseError: ('Error while connecting to database:\n- SQLCODE: -902\n- Unable to complete network request to host "localhost".\n- Failed to establish a connection.', -902, 335544721)
如何解决这个问题?帮助和感谢。