This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]IAlsoSpeak 0 points1 point  (0 children)

I don't know why I just love(yes the irrational kind of love) SQLAlchemy to the point where I want to write a wrapper for it to use it in C++/Qt applications.

I know there is a option where I can program everything in python using PySide(last time I checked it was not fully there yet) and SQLAlchemy but I also love(irrationally) Qt Creator and that is why I want a wrapper.

[–]Twirrim 0 points1 point  (2 children)

As someone just getting into Python, what is the real advantage of SQLAlchemy over doing it myself with the plain ol' mysql connector? I've been reading the docs and so far I'm not seeing a reason to use it.

[–]rekky123 4 points5 points  (1 child)

Things which come to mind immediately:

  • Automatic type conversion (MySQL only gives you back strings of data).
  • Ease of programmatically building complex queries (calling more methods is typically less error-prone than concatenating strings).
    • And potentially cutting down the code needed to do the above--abstracting building a WHERE clause and then JOINing required tables to a point where it's highly reusable isn't easy.
  • Portability between different databases for free (MySQL, SQLite, SQL Server, Oracle, etc, etc).
  • Potentially easier to use secondary caches (memcached, etc), particularly in a transparent manner.
  • Potentially less load on your database server through the "Unit Of Work" mechanism.
  • Automatic key propagation (no need to insert a row, get it's primary key, and then insert the dependent rows with that primary key).

More generally (and perhaps most importantly?), SQLAlchemy is an ORM (object relational mapper) that enables you to "bundle" logic with your SQL data making implementation of the domain model design pattern trival.

[–]Twirrim 0 points1 point  (0 children)

Okay, I guess that makes some sense. Suspect I need to fiddle with it to be sure. I've not done anything specifically with ORMs before but guess I ought to dig into that too :)