Working with databases
In addition to working with files, it’s very common to work with databases. Polars has integrations with various databases, whether they’re hosted in the cloud or on-premises. Once you understand how to work with one database in Polars, you can apply the same patterns to various other databases.
In this recipe, we’ll specifically look at ways to read from and write to a popular database: Postgres. We’ll look at how to work with cloud databases in Chapter 11, Working with Common Cloud Data Sources.
Getting ready
This recipe requires a few additional dependencies. You’ll need to install the following libraries:
connectorx
adbc-driver-postgresql
pyarrow
pg8000
(orpsycopg2
)
You’ll also need to have a Postgres database on your local machine. You can refer to the following websites for more information on how to install a Postgres database locally: