我可以通过以下命令使用 Firebird ISQL Tool (Firebird 3.0.4) 连接到我的 Firebird 数据库:
connect "C:\Documents\database.db" user 'USER' password 'PASSWORD';
当我想在 Python 脚本(Windows10 64 位上的 Python v3.7.7)中,在包括 fdb v2.0.1 甚至 firebirdsql v1.1.3 的虚拟环境中执行此操作时,我不能并且系统地出现错误。
import fdb
con = fdb.connect(database="C:\Documents\database.db", user='USER' password='PASSWORD'')
DatabaseError: ('连接数据库时出错:\n- SQLCODE: -902\n- 无法完成对主机 "xnet://Global\FIREBIRD" 的网络请求。', -902, 335544721)
或者
con = fdb.connect(host='localhost', database="D:\Documents\database.db", user= 'USER' password= 'PASSWORD'')
DatabaseError: ('连接数据库时出错:\n- SQLCODE: -902\n- 无法完成对主机“localhost”的网络请求。\n- 建立连接失败。', -902, 335544721)
或者
con = fdb.connect(dsn="localhost:C:\Documents\database.db", user='USER' password='PASSWORD'')
DatabaseError: ('连接数据库时出错:\n- SQLCODE: -902\n- 无法完成对主机“localhost”的网络请求。\n- 建立连接失败。', -902, 335544721)
或者
import firebirdsql
con = firebirdsql.connect(host='localhost', database="D:\Documents\database.db", user='USER' password='PASSWORD'')
如果您有任何想法,欢迎您,因为我被卡住了。