Note
The Firebird dialect within SQLAlchemy is not currently supported. It is not tested within continuous integration and is likely to have many issues and caveats not currently handled. Consider using the external dialect instead.
Firebird offers two distinct dialects (not to be confused with a SQLAlchemy Dialect):
The SQLAlchemy Firebird dialect detects these versions and adjusts its representation of SQL accordingly. However, support for dialect 1 is not well tested and probably has incompatibilities.
Firebird locks tables aggressively. For this reason, a DROP TABLE may hang until other transactions are released. SQLAlchemy does its best to release transactions as quickly as possible. The most common cause of hanging transactions is a non-fully consumed result set, i.e.:
result = engine.execute(text("select * from table")) row = result.fetchone() return
Where above, the CursorResult has not been fully consumed. The connection will be returned to the pool and the transactional state rolled back once the Python garbage collector reclaims the objects which hold onto the connection, which often occurs asynchronously. The above use case can be alleviated by calling first() on the CursorResult which will fetch the first row and immediately close all remaining cursor/connection resources.
Firebird 2.0 supports returning a result set from inserts, and 2.1 extends that to deletes and updates. This is generically exposed by the SQLAlchemy returning() method, such as:
# INSERT..RETURNING result = table.insert().returning(table.c.col1, table.c.col2).\ values(name='foo') print(result.fetchall()) # UPDATE..RETURNING raises = empl.update().returning(empl.c.id, empl.c.salary).\ where(empl.c.sales>100).\ values(dict(salary=empl.c.salary * 1.1)) print(raises.fetchall())
Constant | RESERVED_WORDS |
Undocumented |
Variable | colspecs |
Undocumented |
Variable | ischema_names |
Undocumented |
Class | _FBDateTime |
Undocumented |
Class | _StringType |
Base for Firebird string types. |
Class | FBCompiler |
Firebird specific idiosyncrasies |
Class | FBDDLCompiler |
Firebird syntactic idiosyncrasies |
Class | FBDialect |
Firebird dialect |
Class | FBExecutionContext |
No class docstring; 1/1 method documented |
Class | FBIdentifierPreparer |
Install Firebird specific reserved words. |
Class | FBTypeCompiler |
Undocumented |