Warning: Got 'None' querying 'table_name' from all_cons_columns - does the user have proper rights to the table?

85 views
Skip to first unread message

Miguel Branco

unread,
Aug 22, 2018, 6:10:25 AM8/22/18
to sqlalchemy
I'm running the code below against an oracle database:

from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base, DeferredReflection

Base = declarative_base(cls=DeferredReflection)

class User(Base):
    __tablename__ = 'user'
    __table_args__ = {'schema':'si'}

#Create a session to use the tables    
engine = create_engine('oracle://teste:te...@172.16.1.34:1512/prod')

Base.prepare(engine)

lst_col= [c.name for c in User.__table__.columns]
print (lst_col, len(lst_col))


But I'm getting a warning with the follow message:
python3.6/site-packages/sqlalchemy/dialects/oracle/base.py:1653: SAWarning: Got 'None' querying 'table_name' from all_cons_columns - does the user have proper rights to the table?

The query runs, but with the warning.

In the tests I made I see that if I give "select any table" privilege to the user it runs without any warning, but for security reasons I don't wan't to give that kind of privilege that gives the user possibility to query any table in the all database. I gave all permissions on that table to the "teste" user, and by sql it's possible to query and do any operations in the table, also it's possible to do all operation by python but with the warning.

Can you please help me find what I doing wrong, or what is the problem?

Miguel Branco

unread,
Aug 22, 2018, 11:38:33 AM8/22/18
to sqlalchemy
Thanks, found the problem!

The one of foreign key was pointing to one table that I don't have permission.
Reply all
Reply to author
Forward
0 new messages