How to perform table mapping / introspection in SQLAlchemy from a Sybase database using Python?

Some useful stackoverflow users have noted that neither pyodbc plugins nor python-sybase support Sybase table reflection in SQLAlchemy .

So my question is: are there alternatives that exist to reflect database metadata for tables in a Sybase deployment? Or, if this is not possible, is there a reasonable way to monkey patch and / or hack a solution to supplant table metadata for parsing and query building?

+4
source share
1 answer

it all comes down to invoking the information scheme provided by the database, which is a set of tables and / or views that you can select, which then return data about tables, columns, and everything else.

In the case of Sybase, they really have a very tight format for their information scheme (mainly because of the 16 + 16 column format for representing the foreign key constraint ), so when I created the Sybase dialogs, I left some of the reflection in the "todo" work. There is no technical reason why this is impossible to do, it is just a long and tedious job, and so far we practically do not use Sybase dialogs.

If you want to work out some basic queries to get table and column names, we can pass them directly to SQLAlchemy. The scheme you will work with is documented in this section: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.tables/html/tables/tables2. htm and there you will watch sysobjects , syscolumn and sysreferences .

+5
source

Source: https://habr.com/ru/post/1400116/


All Articles