Question

I'm making a small python game with pygame. I'd like to be able to have multiple profiles with different stats, upgrades, etc. My biggest problem is storing this information persistently. I've already thought about MySql but I don't know how I could connect to it and I would prefer some way to be able to distribute it without requiring a database. Any suggestions? Many thanks.

Was it helpful?

Solution

You can use the sqlite3 module which comes with python or you could use the shelve module

You can use the shelve module as an object database and just save the user classes directly.

The sqlite3 module will let you store a relational database in a file. It's used by firefox for example.

OTHER TIPS

sqllite3 will probably be the easiest way forward. It's lightweight and doesn't need to be installed by users. To access it though, consider using an ORM (Object Relational Mapper) to simplify things. SQL Alchemy and Storm are both good tools.

An ORM deals with the nitty-gritty of writing SQL code and so forth. If you want to hop between databases, it's often just a matter of changing a single line of code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top