OpenObject Query Parser


Keywords
hacktoberfest, openerp, openobject, orm, parser, query, sql
License
MIT
Install
pip install ooquery==0.14.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')
])