The Complete SQLAlchemy Manual

by Alex
The Complete SQLAlchemy Manual

SQLAclhemy is the de facto framework for dealing with relational databases in Python. It was created by Mike Bayer in 2005. SQLAlchemy allows you to work with MySQL, MS-SQL, PostgreSQL, Oracle, SQLite and other databases.

Why use SQLAlchemy

The most important feature of SQLAlchemy is its ORM. ORM or Object Relational Mapper allows you to work with a database using object-oriented code without using SQL queries. Another feature of SQLAlchemy is that the application code will remain the same regardless of the database used. This allows you to easily migrate from one database to another without rewriting the code. SQLAlchemy has a component called SQLAlchemy Core. It is an abstraction over traditional SQL. It provides an SQL Expression Language that allows you to generate SQL statements using Python constructs. Unlike ORM, which focuses on models and objects, Core focuses on tables, columns, indexes, and so on (similar to conventional SQL). SQL Expression Language is very similar to SQL, but it is standardized, so it can be used in different databases. SQLAlchemy ORM and Core can be used independently of each other. Under the hood, SQLAlchemy ORM uses Core.

So which to use: Core or ORM?

The point of ORM is to simplify the database process. In the process adds some complexity, but it is imperceptible if you are not working with very large amounts of data. For most projects ORM will be enough, but where there is a lot of data, it is worth working with pure SQL.

Who uses SQLAlchemy

  1. Reddit
  2. Hulu
  3. Fedora Project
  4. Dropbox
  5. OpenStack
  6. and many others.

SQLAlchemy tutorials

You need to have a basic knowledge of Python and SQL to understand the tutorial.

  1. Installing SQLAlchemy and connecting to the database.
  2. Creating a database schema in SQLAlchemy Core.
  3. Performing CRUD operations with SQLAlchemy Core.
  4. Creating a database schema in SQLAlchemy ORM.
  5. Performing a CRUD operation with the SQLAlchemy ORM.

Related Posts

LEAVE A COMMENT