使用 firebirdsql 连接本地主机 fdb 文件时连接被拒绝
connection refused while using firebirdsql to connect localhost fdb file
我正在尝试使用 firebirdsql 在 Ubuntu 中读取 fdb 文件:
conn = firebirdsql.connect(host='localhost', database='db.fdb',
user='sysdba', password='masterkey', charset='utf8')
但是在连接的时候,就说Connection refused
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/.local/lib/python3.6/site-packages/firebirdsql/__init__.py", line 94, in connect
conn = Connection(**kwargs)
File "~/.local/lib/python3.6/site-packages/firebirdsql/fbcore.py", line 595, in __init__
self.sock = SocketStream(self.hostname, self.port, self.timeout, cloexec)
File "~/.local/lib/python3.6/site-packages/firebirdsql/socketstream.py", line 46, in __init__
self._sock = socket.create_connection((host, port), timeout)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
代码在Windows服务器上运行良好,但在Ubuntu上无法建立连接,我该如何解决?
您在评论中指出您的机器上没有安装 Firebird 服务器。由于没有服务器侦听本地主机端口 3050,您会收到 连接被拒绝 错误。
你用的那个firebirdsql是纯驱动Python不是说它可以自己打开数据库文件,是说它不使用本机库建立连接,但是它在 Python 中实现了 Firebird TCP/IP 有线协议。您将需要一个 Firebird 服务器(本地主机或远程)才能连接。
此外:服务器通常无法访问您主目录中的文件。
我正在尝试使用 firebirdsql 在 Ubuntu 中读取 fdb 文件:
conn = firebirdsql.connect(host='localhost', database='db.fdb',
user='sysdba', password='masterkey', charset='utf8')
但是在连接的时候,就说Connection refused
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/.local/lib/python3.6/site-packages/firebirdsql/__init__.py", line 94, in connect
conn = Connection(**kwargs)
File "~/.local/lib/python3.6/site-packages/firebirdsql/fbcore.py", line 595, in __init__
self.sock = SocketStream(self.hostname, self.port, self.timeout, cloexec)
File "~/.local/lib/python3.6/site-packages/firebirdsql/socketstream.py", line 46, in __init__
self._sock = socket.create_connection((host, port), timeout)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
代码在Windows服务器上运行良好,但在Ubuntu上无法建立连接,我该如何解决?
您在评论中指出您的机器上没有安装 Firebird 服务器。由于没有服务器侦听本地主机端口 3050,您会收到 连接被拒绝 错误。
你用的那个firebirdsql是纯驱动Python不是说它可以自己打开数据库文件,是说它不使用本机库建立连接,但是它在 Python 中实现了 Firebird TCP/IP 有线协议。您将需要一个 Firebird 服务器(本地主机或远程)才能连接。
此外:服务器通常无法访问您主目录中的文件。