Instead of using ORM, I am considering the following approach in Python and MySQL without ORM (SQLObject / SQLAlchemy). I would like to receive some feedback on whether this could have any negative long-term consequences, because in the short term it seems wonderful from what I can say.
Instead of translating a string from the database to an object:
- each table is represented by a class
- the string is retrieved as a dict
the object representing the cursor provides access to the table as follows:
cursor.mytable.get_by_ids (low, high)
removal means setting time_of_removal at the current time
Thus, essentially, this eliminates the need for ORM, since each table has a class to represent and within that class, a separate dict represents each row.
Type mapping is trivial because every dict (row) that is a first class object in python / blub allows you to recognize the class of the object and, in addition, the low-level database library in Python handles the conversion of types in the field level to the corresponding application types.
If you see any potential problems walking down this road, please let me know. Thanks.
tirus source
share