Engines, on SQLAlchemy, are used to manage two crucial factors: Pools and Dialects. Whenever we want to use SQLAlchemy to interact with a database, we need to create an Engine. Also, to learn about what other database engines we can use (like MySQL or Oracle), take a look at the official list of database interfaces available. To better understand the DBAPI specification, what functions it requires, and how these functions behave, take a look into the Python Enhancement Proposal that introduced it. Other Python drivers communicate with PostgreSQL as well, but psycopg is the best candidate since it fully implements the DBAPI specification and has great support from the community. In this article, we are going to install and use the most popular PostgreSQL DBAPI implementation available: psycopg. Consequently, whenever we use a Python module that adheres to the specification, we can rest assured that we will find these functions and that they will behave as expected. Although we won't interact with this API directly-we will use SQLAlchemy as a facade to it-it's good to know that it defines how common functions like connect, close, commit, and rollback must behave. The Python DBAPI (an acronym for DataBase API) was created to specify how Python modules that integrate with databases should expose their interfaces. The following sections will introduce important concepts that every Python developer needs to understand before dealing with SQLAlchemy applications. Besides that, with SQLAlchemy, boilerplate code to handle tasks like database connections is abstracted away to let developers focus on business logic.īefore diving into the ORM features provided by SQLAlchemy, we need to learn how the core works. SQLAlchemy provides a standard interface that allows developers to create database-agnostic code to communicate with a wide variety of database engines.Īs we will see in this article, SQLAlchemy relies on common design patterns (like Object Pools) to allow developers to create and ship enterprise-grade, production-ready applications easily. Most of the times, this library is used as an Object Relational Mapper (ORM) tool that translates Python classes to tables on relational databases and automatically converts function calls to SQL statements. SQLAlchemy is a library that facilitates the communication between Python programs and databases.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |