-: Hi guys, and welcome back.
In this quick video, I just wanted to tell you
about thread and process safety in psycopg2
and also how you can use async and await
with PostgreSQL, in case you're interested in doing that.
So first of all, psycopg2 is thread-safe,
but it doesn't support asynchronous out-of-the-box.
So you can't use things like async and await directly.
You can use the SELECT module in order to essentially pull
the database or let the database tell you when you're ready
to receive or send information to Postgres,
but it's a bit clunky.
So the official documentation has a guide on how to do that,
essentially, and I'm gonna link it
in the resources section of this lecture.
But it's not ideal, I wouldn't use it.
So instead, if you want to use async and await
for asynchronous development with Postgres
so that you can use, for example, in event loop
using Postgres, you can use a AIOPG,
which stands for async IO, PostgreSQL.
So if you want to do that, please have a look
at the AIOPG website, it has a lot of information.
Overall, it's pretty similar to psycopg2, indeed.
It uses psycopg2 behind the scenes, but it does add support
for async and await a bit more easily without having to use
the SELECT module.
So I'm gonna leave that link in the resources section
of this video.
If you want to take a look at that, then please do,
and if not, just remember that it is possible to use async
and await with Postgres with AIOPG, in case you need
that later on.
All right, thank you guys for joining me in this video.
I'll see you in the next one.