Answer the question
In order to leave comments, you need to log in
Analogue of query to PostgreSQL in sqlalchemy?
Hello, how to translate a query to the database of the form:
select * from db_users where nnr_us = '22' order by nnr_filial, nnr_cod;
SELECT datname FROM pg_database;
table_init = db.Table("pg_database", metadata, autoload=True, autoload_with=engine)
query = db.select([db.text("datname"), table_init]) # select [what] from [where] like in RAW
connection.execute(query)
C:\Users\123\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sqlalchemy\dialects\postgresql\base.py:2972: SAWarning: Did not recognize type 'xid' of column 'datfrozenxid '
"Did not recognize type '%s' of column '%s'" % (attype, name)
C:\Users\123\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sqlalchemy\ dialects\postgresql\base.py:2972: SAWarning: Did not recognize type 'xid' of column 'datminmxid'
"Did not recognize type '%s' of column '%s'" % (attype, name)
C:\Users \123\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sqlalchemy\dialects\postgresql\base.py:2972: SAWarning: Did not recognize type 'aclitem' of column 'datacl'
"Did not recognize type '%s' of column '%s'" % (attype, name)
C:\Users\123\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sqlalchemy\engine\reflection.py:919: SAWarning: index key 'oid' was not located in columns for table ' pg_database'
"columns for table '%s'" % (flavor, c, table_name)
Answer the question
In order to leave comments, you need to log in
engine = db.create_engine(f'postgresql://{username}:{password}@{ip}/db_test')
table_init = db.Table('table_users', metadata, autoload=True, autoload_with=engine)
query = db.select([db.text("*"), table_init]).where(table_init.columns.nnr_us == '22').order_by(table_init.columns.nnr_filial)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question