navapbc / template-application-flask

Apache License 2.0
7 stars 3 forks source link

Upgrade to psycopg3 from version 2 #201

Closed chouinar closed 11 months ago

chouinar commented 11 months ago

Ticket

https://github.com/navapbc/template-application-flask/issues/200

Changes

Upgraded psycopg, the library that connects to Postgres for SQLAlchemy, to version 3.

Context for reviewers

Version 2 was named psycopg2 but version 3 is just psycopg so that they can upgrade without changing the package name moving forward.

Changing the connection string to postgresql+psycopg tells SQLAlchemy internally to use the new library: https://docs.sqlalchemy.org/en/20/dialects/postgresql.html#dialect-postgresql-psycopg-connect

Since we only have a few direct interactions with psycopg, the changes were fairly minimal, just adjusting the DB connection info object slightly.

Testing

Migrations, unit tests, and other automations still running fine.

Was able to pull up swagger and read/write to the DB via our endpoints.