Python, FDB - Firebird timeout

725 Views Asked by At

I'm writing a small script with python and the module fdb (http://pythonhosted.org//fdb/index.html) which reads data from a firebird database and then writes it into a postgres database. (With psycopg2 module)

Everything works fine except one thing, If I have a query from the firebird database and the connection breaks the program hangs because there is no timeout.

I have searched the fdb documentation but there is no option for it.

How i could add a timeout to my sql queries? or what would be the best way to implement this?

1

There are 1 best solutions below

0
On

Since Firebird 4.0, Firebird has statement timeouts. Statement timeouts can be configured on three levels:

  • Database-level, in firebird.conf and/or databases.conf with setting StatementTimeout (timeout in seconds). This establishes the upper-level of a timeout (that means, timeouts on session or statement levels can be lower, but higher values will be ignored)
  • Session-level, using the statement SET STATEMENT TIMEOUT, which will configure the default timeout for statements in the current session (connection).
  • Statement-level, using the low-level API. As far as I know, this isn't exposed in FDB nor in its successor, firebird-driver.

That said, the statement timeout settings will not protect against broken connections.