Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between sqlalchemy core and ORM?

Tags:

What is the difference of purpose between SQLAlchemy Core and SQLAlchemy ORM?

like image 690
Vincent Avatar asked Apr 08 '17 22:04

Vincent


People also ask

Is SQLAlchemy an ORM?

SQLAlchemy is a library that facilitates the communication between Python programs and databases. 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.

What is core and ORM?

The ORM is, as the name implies, an object-relational mapper: Its purpose is to represent database relations as Python objects. The core is a query builder.

Is SQLAlchemy better than Django ORM?

Agree with all previous answers: yes, SQLAlchemy is really more powerful than Django ORM, gives you a real control over your SQL and is very explicit. But 90% of our work is just simple create/read/update/delete or finding object by id.

Is Flask-SQLAlchemy ORM?

Flask-SQLAlchemy is an extension for Flask that adds support for SQLAlchemy to your application. It aims to simplify using SQLAlchemy with Flask by providing useful defaults and extra helpers that make it easier to accomplish common tasks. See the SQLAlchemy documentation to learn how to work with the ORM in depth.


1 Answers

The ORM is, as the name implies, an object-relational mapper: Its purpose is to represent database relations as Python objects.

The core is a query builder. Its purpose is to provide a programmatic means to generate SQL queries (and DDL) -- but the results of those queries are just tuples (with a little extra magic), not objects of your own ("your" being, in this case, "the application developer's") design.

In general, if you're trying to programmatically build queries (particularly based on information only available at runtime), you should be using the core. If you're trying to build your application MVC-style and want database-backed objects to be the "model", you should be using the ORM.

like image 183
Charles Duffy Avatar answered Sep 27 '22 21:09

Charles Duffy