pauldex / sqlalchemy-firebird

A Firebird dialect for SQLAlchemy using the firebird-driver and/or fdb python Firebird driver
MIT License
22 stars 15 forks source link

Embedded connection error #54

Closed tnjunior closed 1 year ago

tnjunior commented 1 year ago

Hi, I'm trying to establish an embedded connection to a database. However, it's reporting an error. engine = create_engine("firebird://sysdba@/C:/temp/MY_PROJECT.FDB?charset=UTF8") engine.connect() Traceback (most recent call last): File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 145, in init self._dbapi_connection = engine.raw_connection() File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 3293, in raw_connection return self.pool.connect() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 452, in connect return _ConnectionFairy._checkout(self) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 1268, in _checkout fairy = _ConnectionRecord.checkout(pool) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 716, in checkout rec = pool._do_get() File "C:\Python310\lib\site-packages\sqlalchemy\pool\impl.py", line 168, in _do_get with util.safe_reraise(): File "C:\Python310\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "C:\Python310\lib\site-packages\sqlalchemy\pool\impl.py", line 166, in _do_get return self._create_connection() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 393, in _create_connection return _ConnectionRecord(self) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 678, in init self.connect() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 902, in connect with util.safe_reraise(): File "C:\Python310\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 898, in connect self.dbapi_connection = connection = pool._invoke_creator(self) File "C:\Python310\lib\site-packages\sqlalchemy\engine\create.py", line 637, in connect return dialect.connect(*cargs, *cparams) File "C:\Python310\lib\site-packages\sqlalchemy\engine\default.py", line 616, in connect return self.loaded_dbapi.connect(cargs, **cparams) File "C:\Python310\lib\site-packages\firebird\driver\core.py", line 2128, in connect return make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(), File "C:\Python310\lib\site-packages\firebird\driver\core.py", line 2044, in make_connection att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING) File "C:\Python310\lib\site-packages\firebird\driver\interfaces.py", line 1283, in attach_database self._check() File "C:\Python310\lib\site-packages\firebird\driver\interfaces.py", line 111, in _check raise self.report(DatabaseError, self.status.get_errors()) firebird.driver.types.DatabaseError: Unable to complete network request to host "xnet://Global\FIREBIRD". The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2022.3.2\plugins\python-ce\helpers\pydev\pydevconsole.py", line 364, in runcode coro = func() File "", line 1, in File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 3269, in connect return self._connection_cls(self) File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 147, in init Connection._handle_dbapi_exception_noconnection( File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 2431, in _handle_dbapi_exception_noconnection raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 145, in init self._dbapi_connection = engine.raw_connection() File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 3293, in raw_connection return self.pool.connect() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 452, in connect return _ConnectionFairy._checkout(self) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 1268, in _checkout fairy = _ConnectionRecord.checkout(pool) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 716, in checkout rec = pool._do_get() File "C:\Python310\lib\site-packages\sqlalchemy\pool\impl.py", line 168, in _do_get with util.safe_reraise(): File "C:\Python310\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "C:\Python310\lib\site-packages\sqlalchemy\pool\impl.py", line 166, in _do_get return self._create_connection() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 393, in _create_connection return _ConnectionRecord(self) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 678, in init self.connect() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 902, in connect with util.safe_reraise(): File "C:\Python310\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 898, in connect self.dbapi_connection = connection = pool._invoke_creator(self) File "C:\Python310\lib\site-packages\sqlalchemy\engine\create.py", line 637, in connect return dialect.connect(*cargs, *cparams) File "C:\Python310\lib\site-packages\sqlalchemy\engine\default.py", line 616, in connect return self.loaded_dbapi.connect(cargs, **cparams) File "C:\Python310\lib\site-packages\firebird\driver\core.py", line 2128, in connect return make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(), File "C:\Python310\lib\site-packages\firebird\driver\core.py", line 2044, in make_connection att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING) File "C:\Python310\lib\site-packages\firebird\driver\interfaces.py", line 1283, in attach_database self._check() File "C:\Python310\lib\site-packages\firebird\driver\interfaces.py", line 111, in _check raise self.report(DatabaseError, self.status.get_errors()) sqlalchemy.exc.DatabaseError: (firebird.driver.types.DatabaseError) Unable to complete network request to host "xnet://Global\FIREBIRD". (Background on this error at: https://sqlalche.me/e/20/4xp6)

pauldex commented 1 year ago

For an embedded connection, you’ll need to add a parameter to the connection string indicating the full path to the fbclient.dll/fbclient.so file of your embedded server.

If you’re using fdb, the parameter name is fb_library_name. For firebird-driver, the parameter name is fb_client_library.

Using your connection string as a base, an example connection string for Windows using fdb would be:

"firebird+fdb://sysdba@/C:/temp/MY_PROJECT.FDB?charset=UTF8?fb_library_name=c:/temp/MY_SERVER_DIRECTORY/fbclient.dll”

Using firebird-driver, the connection string would be:

"firebird+firebird://sysdba@/C:/temp/MY_PROJECT.FDB?charset=UTF8?fbclient library =c:/temp/MY_SERVER_DIRECTORY/fbclient.dll”

Hope this helps,

Paul

From: tnjunior @.> Sent: Thursday, June 22, 2023 7:50 AM To: pauldex/sqlalchemy-firebird @.> Cc: Subscribed @.***> Subject: [pauldex/sqlalchemy-firebird] Embedded connection error (Issue #54)

Hi, I'm trying to establish an embedded connection to a database. However, it's reporting an error. engine = create_engine("firebird://sysdba@/C:/temp/MY_PROJECT.FDB?charset=UTF8") engine.connect() Traceback (most recent call last): File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 145, in init self._dbapi_connection = engine.raw_connection() File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 3293, in raw_connection return self.pool.connect() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 452, in connect return _ConnectionFairy._checkout(self) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 1268, in _checkout fairy = _ConnectionRecord.checkout(pool) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 716, in checkout rec = pool._do_get() File "C:\Python310\lib\site-packages\sqlalchemy\pool\impl.py", line 168, in _do_get with util.safe_reraise(): File "C:\Python310\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "C:\Python310\lib\site-packages\sqlalchemy\pool\impl.py", line 166, in _do_get return self._create_connection() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 393, in _create_connection return _ConnectionRecord(self) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 678, in init self.connect() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 902, in connect with util.safe_reraise(): File "C:\Python310\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 898, in connect self.dbapi_connection = connection = pool._invoke_creator(self) File "C:\Python310\lib\site-packages\sqlalchemy\engine\create.py", line 637, in connect return dialect.connect(*cargs, *cparams) File "C:\Python310\lib\site-packages\sqlalchemy\engine\default.py", line 616, in connect return self.loaded_dbapi.connect(cargs, **cparams) File "C:\Python310\lib\site-packages\firebird\driver\core.py", line 2128, in connect return make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(), File "C:\Python310\lib\site-packages\firebird\driver\core.py", line 2044, in make_connection att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING) File "C:\Python310\lib\site-packages\firebird\driver\interfaces.py", line 1283, in attach_database self._check() File "C:\Python310\lib\site-packages\firebird\driver\interfaces.py", line 111, in _check raise self.report(DatabaseError, self.status.get_errors()) firebird.driver.types.DatabaseError: Unable to complete network request to host "xnet://Global\FIREBIRD". The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2022.3.2\plugins\python-ce\helpers\pydev\pydevconsole.py", line 364, in runcode coro = func() File "", line 1, in File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 3269, in connect return self._connection_cls(self) File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 147, in init Connection._handle_dbapi_exception_noconnection( File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 2431, in _handle_dbapi_exception_noconnection raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 145, in init self._dbapi_connection = engine.raw_connection() File "C:\Python310\lib\site-packages\sqlalchemy\engine\base.py", line 3293, in raw_connection return self.pool.connect() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 452, in connect return _ConnectionFairy._checkout(self) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 1268, in _checkout fairy = _ConnectionRecord.checkout(pool) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 716, in checkout rec = pool._do_get() File "C:\Python310\lib\site-packages\sqlalchemy\pool\impl.py", line 168, in _do_get with util.safe_reraise(): File "C:\Python310\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "C:\Python310\lib\site-packages\sqlalchemy\pool\impl.py", line 166, in _do_get return self._create_connection() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 393, in _create_connection return _ConnectionRecord(self) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 678, in init self.connect() File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 902, in connect with util.safe_reraise(): File "C:\Python310\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in exit raise exc_value.with_traceback(exc_tb) File "C:\Python310\lib\site-packages\sqlalchemy\pool\base.py", line 898, in connect self.dbapi_connection = connection = pool._invoke_creator(self) File "C:\Python310\lib\site-packages\sqlalchemy\engine\create.py", line 637, in connect return dialect.connect(*cargs, *cparams) File "C:\Python310\lib\site-packages\sqlalchemy\engine\default.py", line 616, in connect return self.loaded_dbapi.connect(cargs, **cparams) File "C:\Python310\lib\site-packages\firebird\driver\core.py", line 2128, in connect return make_connection(False, dsn, db_config.utf8filename.value, dpb.get_buffer(), File "C:\Python310\lib\site-packages\firebird\driver\core.py", line 2044, in make_connection att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING) File "C:\Python310\lib\site-packages\firebird\driver\interfaces.py", line 1283, in attach_database self._check() File "C:\Python310\lib\site-packages\firebird\driver\interfaces.py", line 111, in _check raise self.report(DatabaseError, self.status.get_errors()) sqlalchemy.exc.DatabaseError: (firebird.driver.types.DatabaseError) Unable to complete network request to host "xnet://Global\FIREBIRD". (Background on this error at: https://sqlalche.me/e/20/4xp6)

— Reply to this email directly, view it on GitHub https://github.com/pauldex/sqlalchemy-firebird/issues/54 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ABX7Z67FLIMUVLC7D3LAIOTXMRLQJANCNFSM6AAAAAAZQKOGAI . You are receiving this because you are subscribed to this thread. https://github.com/notifications/beacon/ABX7Z66VMTFGFVCYOLRDNYDXMRLQJA5CNFSM6AAAAAAZQKOGAKWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHGS7N53A.gif Message ID: @. @.> >

pauldex commented 1 year ago

I’ve updated the connection strings to the correct format.

Using your connection string as a base, an example connection string for Windows using fdb would be:

"firebird+fdb://sysdba@/C:/temp/MY_PROJECT.FDB?charset=UTF8&fb_library_name=c:/temp/MY_SERVER_DIRECTORY/fbclient.dll”

Using firebird-driver, the connection string would be:

"firebird+firebird://sysdba@/C:/temp/MY_PROJECT.FDB?charset=UTF8&fbclient library =c:/temp/MY_SERVER_DIRECTORY/fbclient.dll”

Paul

fdcastel commented 1 year ago

I believe this one could be closed, now.

tnjunior commented 1 year ago

Hi, Sorry, I forgot to respond.

Yes, it can be closed.

Teodorico N. R. Junior skype: teodoriconicolaurodriguesjunior


De: F.D.Castel @.> Enviado: quinta-feira, 31 de agosto de 2023 13:51 Para: pauldex/sqlalchemy-firebird @.> Cc: tnjunior @.>; Author @.> Assunto: Re: [pauldex/sqlalchemy-firebird] Embedded connection error (Issue #54)

I believe this one could be closed, now.

— Reply to this email directly, view it on GitHubhttps://github.com/pauldex/sqlalchemy-firebird/issues/54#issuecomment-1701411501, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGTUJW5EVMQGOINOWUSRLGLXYC6KJANCNFSM6AAAAAAZQKOGAI. You are receiving this because you authored the thread.Message ID: @.***>