SQLAlchemy is arguably the most powerful and ubiquitous ORM framework for Python.
At Oursky, we have been using SQLAlchemy for quite a period of time and appreciated the flexibility and elegance it provides over the Data Mapper abstraction. No doubt, it works very well for modern web applications but what about long-running background jobs? Would the abstraction get in your ways? (tl;dr: yes, but we still prefer it)
Here are some hands-on experiences from us.
We built a popular iOS application with a song recommendation system at the backend. The system suggests a top list for 20 popular songs.
Previously our editors hand-picked popular songs by download count and gather a new playlist as a recommendation to users. Now, we want to automate this process and generate the playlist weekly.
In one of the Android app projects at Oursky, we started using Realm for data caching. So users won’t have to look at blank pages when they log back to the app, waiting for remote API results.
We think it’s a minimalistic yet reliable solution, and is worth giving it a shot for your next app. Just beware of the differences between versions, follow the conventions, and pay extra attention when using with other libraries.
More is discussed below in details and with example snippets.
What is Realm?
Realmis the mobile database solution that proposed as a replacement for SQLite & Core Data.
It’s like using SQLite with an ORM (as those who used SQLAlchemy may have experience), with a lot of awesome and convenient methods for data transactions.
However, Realm is NOT built on top of SQLite. It persists on its own persistence engine.
Realm is also cross-platform that supports both iOS and Android, so developers who write Java, Swift, Objective-C can share the same Realm files painlessly.