I have a project coming up that involves a desktop application (tournament scoring for an amateur competition) that probably 99+% of the time will be a single-user on a single machine, no network connectivity, etc. For that, sqlite will likely work beautifully. For those other few times when there are more than one person, with more than one computer, and some form of network... they would ideally need to be able to enter data (event registration and putting in scores) to a central database such as a MySQL or PostgreSQL server. I don't envision a need for synchronizing data between the local (sqlite) and remote databases, just a need to be able to switch via preferences or configuration file which kind of database the program should connect to the next time its started (along with the connection info for any remote database).
I'm fairly new at this kind of programming, and this will likely take me a good while to get where I want it... but I'd prefer to avoid going down the wrong path early on (at least on major things like this). Given my limited understanding of things like ORMs it seems like this would b开发者_开发问答e a near-ideal use for something like SQLAlchemy, no? Or would the 'batteries included' python db-api be generic enough for this kind of task?
TIA,
Monte
Yes, SQLAlchemy will help you to be independent on what SQL database you use, and you get a nice ORM as well. Highly recommended.
I don't see how those 2 use cases would use the same methods. Just create a wrapper module that conditionally imports either the sqlite or sqlalchemy modules or whatever else you need.
精彩评论