psycopg

  • Home
  • Features
  • Install
  • News
  • Recipes
  • psycopg3
  • Sponsors

Psycopg is the most popular PostgreSQL adapter for the Python programming language. Its core is a complete implementation of the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

The psycopg3 project is currently under active development.

Sponsoring this project will help achieve swift completion and ensure the maintenance of psycopg2, psycopg3 and other related projects.

If you use Python and PostgreSQL, and you would like to support the creation of the most advanced adapter between the two systems, please consider becoming a sponsor. Thank you!

Psycopg is released under the terms of the GNU Lesser General Public License, allowing use from both free and proprietary software.

  • Check the features list to see what Psycopg offers
  • Read the Psycopg documentation. Be sure to check the Frequently Asked Questions
  • Install Psycopg!

For help requests and development discussions please subscribe to the mailing list psycopg@postgresql.org.

Latest articles

Building a Django driver for Psycopg 3

Posted by Daniele Varrazzo on 2021-08-02
Tagged as psycopg3, development, recipe

One of the goals of the Psycopg 3 project is to make easy to port code developed from Psycopg 2. For this reason the creation of a Django backend (the module you specify in the settings as your database ENGINE) was a project with a double goal:

  • A Django driver is a way to make Psycopg 3 useful from the start, with the possibility of dropping it in a project transparently and have available, when needed the new features offered (for instance the superior COPY support).
  • The difficulty of introducing Psycopg 3 in the Django codebase and the type of changes required are indicative of the type of problems that could be found porting other projects.

...and it's done! A few days ago, the new Psycopg 3 Django backend could pass the entire Django test suite!

Read more...

Psycopg 2.9 released

Posted by Daniele Varrazzo on 2021-06-16
Tagged as news, release

Psycopg 2.9 has been released!

This is a relatively small release compared to previous major releases. However the creation of the packages took a lot of effort. The previously used CI system now has reduced support for free software projects - it was decided that package building should be moved to GitHub Actions.

Packaging has also become more complex because of the evolution of the Python packaging standards and the need to support multiple architectures (Intel, ARM, PPC...).

Maintaining a project such as Psycopg requires a lot of effort. For this reason, we are extremely grateful to all our sponsors who are enabling the maintenance and development of Psycopg. Thank you very much!

Read more...

Designing a connection pool for psycopg3

Posted by Daniele Varrazzo on 2021-01-17
Tagged as psycopg3, development

The psycopg2 pool is a pretty simple object, little more than... a pool of open connections, and I think it falls short in several ways:

  • the top usability problem is the fact that it cannot be used as context manager;
  • if a connection is broken it is not noticed it until it is used by a client;
  • if minconn connections are already taken, a new one is created and disposed of as soon as finished using, regardless of whether other clients may need it;
  • if more than maxconn connections are requested the client will receive an error.

For psycopg3 I would like something better. I have read around, looking into other pool implementations to figure out what a well designed connection pool ought to do (a very well thought one seems the Java HikariCP) and these are a few ideas I'd like to work on: they are here for a feedback, before I jump into enthusiastically implementing the wrong thing...

Read more...

See all articles...

psycopg2

  • Documentation
  • Source code
  • Bug tracker
  • Download

psycopg3

  • The Project
  • Documentation
  • Source code
  • Bug tracker

Mailing List

  • Subscribe
  • Archives
Tweets by psycopg

© Copyright 2010—2021 by Daniele Varrazzo (at gmail), The Psycopg Team.