kennethreitz / records

SQL for Humans™
https://pypi.python.org/pypi/records/
ISC License
7.14k stars 570 forks source link

Support "Raw" queries to support things like VACUUM #182

Open keeganmccallum opened 5 years ago

keeganmccallum commented 5 years ago

I've found one use case that was a bit difficult, which is using records to perform routine maintenance. I was able to work around with the following code(sql is a records db):

from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
...

vac_conn = sql._engine.raw_connection()
vac_conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
vac_curr = vac_conn.cursor()
vac_curr.execute("VACUUM (ANALYZE)")
vac_conn.close()

It would be great to add a raw flag to the query method, or even just have a raw method to be able to call sql outside of transaction blocks.

kennethreitz commented 5 months ago

interesting

kennethreitz commented 3 months ago

I will fix this.

kennethreitz commented 3 months ago

-raw flag is Perfect!!