Exemplo n.º 1
0
def select(conn, query, print_sql=False, **kwargs):
    try:
        with conn.cursor() as cur:
            sql = sb.sqlrepr(
                sb.Select(sb.Field("ser", "data"), where=query, **kwargs),
                'postgres')
            if print_sql:
                print('SQL> ', sql)
            cur.execute(sql)
            for e in cur.fetchall():
                pprint(e[0])
    finally:
        conn.rollback()
Exemplo n.º 2
0
def select(conn, query, print_sql=False):
    try:
        with conn.cursor() as cur:
            converter = mquery.Converter("mq", "data")
            sql = sb.sqlrepr(
                sb.Select(sb.Field("mq", "data"),
                          where=converter.convert(query)), 'postgres')
            if print_sql:
                print('SQL> ', sql)
            cur.execute(sql)
            for e in cur.fetchall():
                pprint.pprint(e[0])
    finally:
        conn.rollback()
Exemplo n.º 3
0
def select(conn, query, print_sql=False, **kwargs):
    try:
        with conn.cursor() as cur:
            sql = sb.sqlrepr(
                sb.Select(sb.Field("ser", "data"), where=query, **kwargs),
                'postgres'
            )
            if print_sql:
                print('SQL> ', sql)
            cur.execute(sql)
            for e in cur.fetchall():
                pprint(e[0])
    finally:
        conn.rollback()
Exemplo n.º 4
0
def select(conn, query, print_sql=False):
    try:
        with conn.cursor() as cur:
            converter = mquery.Converter("mq", "data")
            sql = sb.sqlrepr(
                sb.Select(sb.Field("mq", "data"), where=converter.convert(query)),
                'postgres'
            )
            if print_sql:
                print 'SQL> ', sql
            cur.execute(sql)
            for e in cur.fetchall():
                print e[0]
    finally:
        conn.rollback()