Psycopg is the most popular PostgreSQL adapter for the Python programming language.
The name Psycopg
does not make sense to me.
I understand the last pg
means Postgres
, but what about Psyco
?
After dealing with a badly written python+postgres driver in the company he worked for at the time, he wrote his own simplified version (psycopg) and: I wanted to call it psychopg (a reference to their psychotic driver) but I typed the name wrong.
It is designed for multi-threaded applications and manages its own connection pool. Other interesting features of the adapter are that if you are using the PostgreSQL array data type, Psycopg will automatically convert a result using that data type to a Python list.
Thread and process safety In DB API 2.0 parlance, Psycopg is level 2 thread safe. The difference between the above two approaches is that, using different connections, the commands will be executed in different sessions and will be served by different server processes.
class cursor. Allows Python code to execute PostgreSQL command in a database session. Cursors are created by the connection. cursor() method: they are bound to the connection for the entire lifetime and all the commands are executed in the context of the database session wrapped by the connection.
I've always thought of it as psycho-Postgres.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With