mardi 10 mars 2015

Database & data access consideration: Client-Server model or ORM approach

The back-end database choice is clear: that will be PostgreSql.
But a question remain... how will we access the data from the application?

Client-Server Model
One of the option is to use a database access library like PsycoPG2 to access the database.
By doing so, we are going to use a Client-Server model. PsycoPG2 does fully implement the Python DB API 2.0 specification.
The advantage is the simplicity of the approah, fews layers between the code and the database means that the code thighly control what's happening within the database. There is a better control on what's happen in the code.

Want to know a bit more about PsycoPG2:

Object Relational Mapping
On the other side, using an ORM approche allows you to concentrate efforts on the Business logic without worry (or lesser) about how to access/extract the data from the database.
Don't need to write your own in-memory data storage layer, lists, sorting, etc... its already done by the ORM.
Source: sqlalchemy.org

One very popular an robust tools in Python is SQLAlchemy which also provide ORM support.
I don't know if this would work like a charm on Windows or Raspberry-Pi.
Any options simplifying the development tasks should always be taken in consideration.
Source: sqlalchemy.org

You can find many information in the tutorial section of SqlAlchemy.org

You can also have a look to the following vidéo


Python SQLAlchemy Tutorial - on the Python Central website

Author: Xiaonuo Gantan
A series of beginner-focused SQLAlchemy tutorials covering a wide range of basic topics. While a lot of the information here is derived from the main documentation, the pace is slower and there are also details culled from other sources, including performance tips, comparison to other ORMs, and design philosophies. A very good effort by author Xiaonuo Gantan.

Aucun commentaire:

Enregistrer un commentaire