-
Notifications
You must be signed in to change notification settings - Fork 2
Q&A: General
Q: Python has stuff like ORMs, DALs, DAOs, and even a database API specification: Why this?
Note: ORM: Object Relational Mapper, DAL: Data Abstraction Layer, DAO: Data Access Object
Because py2store is neither of these. At least not completely. But it should be pointed out that our motivation is similar. Consider the first paragraph of the database API specification PEP 249:
"This API has been defined to encourage similarity between the Python modules that are used to access databases. By doing this, we hope to achieve a consistency leading to more easily understood modules, code that is generally more portable across databases, and a broader reach of database connectivity from Python."
py2store would be more akin to a DAO or a DAL, but at a slightly higher level of abstraction than "database". The focus here is on storage: Saving and loading stuff.
There are many aspects of storage you may or may not want to control: (Physical) persistence, indexing, serialization, caching, validation, etc. What py2store offers are tools to specify all these things somewhere, and then interact with storage through the (python-)simplest API possible.
Q: You really expect me to learn yet another system?
Not at all. One of the things py2store aims to address: Not having to learn a new system. You already know dicts if you know python. Now for most operations, you can just pretend that your store is a dict, and py2store will take care of translating it to s3, mongoDB, sql, etc. You have plenty of stores you can use out-of-the-box. Of course, if you want/need to do something that is not covered, then you'll need to learn a few things on how to extend stores to your use case. But we try to make that easy as well.
Q: But I'm used to saying 'write' to write or 'read' to read data. I'll need to at least change that!
If you really want to use different words for the these operations you can. It's as easy as:
from py2store.trans import insert_aliases
insert_aliases(store, write='write', read='read', delete='remove', list='show', count='num_of_items')and voilà: You can now have those methods you like to use: write, read, remove, show, and num_of_items!