OpenObject Query Parser


Keywords
parser, query, sql, orm, openerp, openobject
License
MIT
Install
pip install ooquery==0.20.1

Documentation

OpenObject Query

Python 2.7 and >=3.5

https://travis-ci.org/gisce/ooquery.svg?branch=master https://coveralls.io/repos/github/gisce/ooquery/badge.svg?branch=master

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')
])