Python 2.7 and >=3.5
Parsers OpenObjectes queries like:
import pyscopg2
from oopgrade.oopgrade import get_foreign_keys
from ooquery import OOQuery
conn = psycopg2.connect("dbname=test user=postgres")
with conn.cursor() as cursor:
def fk_function(table, field):
fks = get_foreign_keys(cursor, table)
return fks[field]
q = OOQuery('account_invoice', fk_function)
sql = q.select(['number', 'state']).where([
('state', '=', 'open'),
('partner_id.name', '=', 'Pepito')
])
cursor.execute(*sql)
Support for reading from joined tables
q = OOQuery('account_invoice', fk_function)
sql = q.select(['number', 'partner_id.name', 'partner_id.vat']).where([
('state', '=', 'open')
])