refactor: upgrade to psycopg3[binary]==3.3.3#12212
refactor: upgrade to psycopg3[binary]==3.3.3#12212bhardwajparth51 wants to merge 10 commits intointernetarchive:masterfrom
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…r stripping in infogami parser
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
|
|
Maybe the approach we should take here is to use it in our application in places that we currently are using it directly, and then do a separate pull request for Infogami. Because I don't think that we are going to be able to just patch in Kogami as a long-term solution. We need to fully improve it at its source. |
|
Agreed, patching config.py is definitely a code smell. We should fix it at the source in the infogami repo instead. Just to make sure we're on the same page for this PR: I am thinking to do a hybrid setup where we have both psycopg2 and psycopg[binary]==3.3.3 in requirements.txt. That way infogami can keep using v2 for now, while we upgrade direct usages like solr_builder to v3. Or should we first, fix the internetarchive/infogami first to update its driver parsing, and then we do a single, clean switch later?" |
|
Let's first the second one first to do a clean switch. I'm also not as
familiar with solr builder so it's better to start with the part were more
familiar with. That being said, I think there may be a case to try just
using psycopg3 directly without web.py in our main codebase to see what the
DX is.
I'm not sure there's a specific need for us to be using the connection
through web.py.
What do you think?
…On Mon, Mar 30, 2026, 1:23 PM Parth Bhardwaj ***@***.***> wrote:
*bhardwajparth51* left a comment (internetarchive/openlibrary#12212)
<#12212?email_source=notifications&email_token=AAHA5AIUB7FN7QGG77A2FMD4TLJVJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJVG44TINZQGQ22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4157947045>
Agreed, patching config.py is definitely a code smell. We should fix it at
the source in the infogami repo instead.
Just to make sure we're on the same page for this PR: I am thinking to do
a hybrid setup where we have both psycopg2 and psycopg[binary]==3.3.3 in
requirements.txt. That way infogami can keep using v2 for now, while we
upgrade direct usages like solr_builder to v3.
Or should we first, fix the internetarchive/infogami first to update its
driver parsing, and then we do a single, clean switch later?"
—
Reply to this email directly, view it on GitHub
<#12212?email_source=notifications&email_token=AAHA5AIUB7FN7QGG77A2FMD4TLJVJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJVG44TINZQGQ22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4157947045>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHA5AOTKNQYZRTCJQXT6CD4TLJVJAVCNFSM6AAAAACXC65HSOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCNJXHE2DOMBUGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Description
Part of #10258 upgrade.
refactor
This PR upgrades Open Library's underlying PostgreSQL driver from
psycopg2to
psycopg[binary]==3.3.3. Following the successful migration of the OpenLibrary database from PostgreSQL 9.3 to 18, this update ensures our application
bindings are modernized and can leverage
psycopg3natively for betterperformance and future async execution.
Changes
requirements.txtto usepsycopg[binary]==3.3.3.driver: psycopgexplicitly todb_parametersinconf/coverstore.yml,conf/infobase.yml, andconf/openlibrary.yml.psycopg.errorsacross
core/db.py,core/edits.py,core/imports.py, andscripts/migrations/.solr_builder.py. Removedcur.itersizewhich is unsupported in psycopg3.openlibrary/config.py): Added a temporary compatibilityshim for
infogami'sparse_db_parameters(), which currently strips thedriverkey. The patch preserves it until the submodule is updated natively.Marked with
# TODOKnown Limitation
infogamiis a submodule that still internally references psycopg2. The configpatch in
openlibrary/config.pyis a deliberate stopgap —to be tracked in #10258.Future Proofing for FastAPI Async
Since
psycopg3natively supportsasyncio, this sets up future FastAPIendpoints to use
AsyncConnectionPoolwithout additional driver changes.Testing
docker compose build hometo pull in the new dependencies.docker compose run --rm home make test-pysuccessfully against therevised stack (
3008 passed, 0 failures).docker compose up) and verify that standarddatabase components resolve properly.
driver: psycopgis present inweb.config.db_parametersafter config load.
Stakeholders
@mekarpeles @RayBB