records icon indicating copy to clipboard operation
records copied to clipboard

Support "Raw" queries to support things like VACUUM

Open keeganmccallum opened this issue 6 years ago • 3 comments

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.

keeganmccallum avatar Jun 25 '19 01:06 keeganmccallum

interesting

kennethreitz avatar Mar 30 '24 00:03 kennethreitz

I will fix this.

kennethreitz avatar May 14 '24 10:05 kennethreitz

-raw flag is Perfect!!

kennethreitz avatar May 14 '24 10:05 kennethreitz