Closed WillForan closed 5 years ago
This is a SQLAlchemy limitation -- it's a generalized ORM so it's not expecting you to hand it a Psycopg2 object it didn't build itself. Your problem seems to be quoting identifiers; all engine fixtures allow quoting identifiers like so:
import sqlalchemy as sqla
def code_to_test(transacted_postgresql_db)
quote = transacted_postgresql_db.id_quoter # this is what you need
query = "INSERT INTO {} ({}) VALUES (:id)".format(quote('mytest'), quote('id'))
transacted_postgresql_db.execute(query, {'id': 2})
Thanks for the quick response! Fortunately, there aren't too many places that will need to be abstracted from psycopg2. Being able to test with pytest-pgsql will make the effort worth it!
Is there a way or any suggestions for using psycopg2 objects in execute()?