79316131

Date: 2024-12-29 18:38:47
Score: 1.5
Natty:
Report link

Thanks to @AdrianKlaver in the comments - got me on the right track.

Here's the solution I went with to ensure a COMMIT was issued:

from sqlalchemy import create_engine
from sqlalchemy.schema import CreateSchema


def main():
    conn_str = "postgresql+psycopg2://philipjoss:Mombassa11@localhost/belgarath_test"

    engine = create_engine(conn_str, echo=True)

    with engine.connect().execution_options(isolation_level="AUTOCOMMIT") as connection:
        with connection.begin():
            connection.execute(CreateSchema("test_schema"))


if __name__ == "__main__":
    main()
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @AdrianKlaver
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Jossy