How to use SQLAlchemy reflection with Sybase? [answer: it turns out that it is not supported!]

I am trying to learn more about the .egg concept and overriding methods in Python. Here is the error message I get:

Traceback (most recent call last): File "C:/local/work/scripts/plmr/plmr_db.py", line 42, in <module> insp.reflecttable(reo_daily_table, column_list) File "build\bdist.win32\egg\sqlalchemy\engine\reflection.py", line 370, in reflecttable File "build\bdist.win32\egg\sqlalchemy\engine\reflection.py", line 223, in get_columns File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 260, in get_columns NotImplementedError 

Here is a specific function from base.py:

 def get_columns(self, connection, table_name, schema=None, **kw): """Return information about columns in `table_name`. Given a :class:`.Connection`, a string `table_name`, and an optional string `schema`, return column information as a list of dictionaries with these keys: name the column name type [sqlalchemy.types#TypeEngine] nullable boolean default the column default value autoincrement boolean sequence a dictionary of the form {'name' : str, 'start' :int, 'increment': int} Additional column attributes may be present. """ raise NotImplementedError() 

So my question is: do I override this function by writing a new method in my main module? Or am I skipping a step somewhere along the way with my import? Or am I just completely out of here?

Any help is appreciated :)

edit: adding my code

 import sys from sqlalchemy import create_engine, select, Table, MetaData from sqlalchemy.engine import reflection dbPath = 'connection_string' engine = create_engine(dbPath, echo=True) connection = engine.connect() #reflect tables into memory meta = MetaData() reo_daily_table = Table('reo_daily',meta) insp = reflection.Inspector.from_engine(engine) column_list=[...] insp.reflecttable(reo_daily_table, column_list) connection.close() 
+2
source share
2 answers

You misunderstood. You do not need to subclass anything, and this problem has nothing to do with eggs and .ini files.

You do not have to instantiate the inspector in this way. If you read SQLAlchemy docs , you will notice that you should not use the Reflection constructor directly; instead you should write

 insp = reflection.Inspector.from_engine(engine) 
+1
source

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


All Articles