I am trying to query an Oracle DB table from sqlalchemy with
session.query(PAY).filter_by(REGION_CODE=record['REGION_CODE'],
AOID=record['AOID'],
COMPANY_CODE=record['COMPANY_CODE']).all()
it returns 1 value, however if do a raw sql
select * from schema.table_name where REGION_CODE = '{record['REGION_CODE']}'
and AOID = '{record['AOID']}' and COMPANY_CODE = '{record['COMPANY_CODE']}
The database has 2 records I get two results. The results have identical values but are 2 different records.
Any one have any idea why the query only returns the single value?
It is possible that SQLAlchemy is prepending a "distinct" clause to the query which will eliminate duplicate rows. You can find out for sure by setting the environment variable DPI_DEBUG_LEVEL
to the value 16
before running the two examples. This will show the SQL statements that are being executed and you can confirm my suspicions!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.