Main components of SQLAlchemy

SQLAlchemy works on top of DB API. It can use psycopg2 to connect to PostgreSQL or any other driver that implements the API, like pg8000. There are several components that belong to the Core of SQLAlchemy:

  • Dialects are used to communicate with a particular database driver. SQLAlchemy has several dialects for different databases such as Oracle, MS SQL Server, PostgreSQL, MySQL, and some others. Each of the dialects of SQLAlchemy requires the respective Python library installed.
  • Connection pooling component is responsible for establishing connections to databases using a dialect, managing connection pools, and providing connection API to the Engine.
  • Engine represents the database to other components performing SQL commands. It is the starting point for an application that is using SQLAlchemy.
  • SQL Expression Language is an abstraction layer that translates high-level API calls to SQL that Engine could execute. It is another component accessible directly to the application using SQLAlchemy.
  • Schema and Types are objects that define a logical data model. They are used by ORM or can be used directly with SQL Expression language to manipulate the data.

Object Relational Mapper or ORM stands on top and uses the Core components. It implements the representation of database records as instances of classes that define business entities. ORM also manages relationships between the classes that are implemented as foreign keys in the database, though this is not mandatory.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset