Text files or Database?

21 views
Skip to first unread message

Daniel Leal

unread,
Jan 28, 2021, 2:44:50 PM1/28/21
to Kivy users support
Hi everyone,

I am trying to learn python/kivy "by doing". Already have a small game working pretty well :)
I arranged a way to code each level's geometry in a matrix stored in an individual text file. The game reads the corresponding level text file that have numbers stored in a matrix form to put the pieces of the game in the right place. But now the game has around 400 levels... so 400 text files...
Does it makes sense to continue like this, or should I start to change to a database? In the past I had some experience with mysql. I was  considering that. I am taking the right decision?
What should I do?

Thank you :)

Geekademy

unread,
Jan 28, 2021, 3:02:43 PM1/28/21
to kivy-...@googlegroups.com

On 2021-01-28 11:44, Daniel Leal wrote:
> Does it makes sense to continue like this, or should I start to change to a
> database? In the past I had some experience with mysql. I was  considering that.
> I am taking the right decision?
> What should I do?

If you decide to go the database route, sqlite support is built in to Python and
would be a much better choice if the data will be local. For a professional
server at a distance, postgres is generally the best choice.

Good luck,

Daniel Leal

unread,
Jan 28, 2021, 4:18:48 PM1/28/21
to Kivy users support
Thanks for your answer and precious information.
What about the main reason that I should consider to make the decision to change or not to change? Do you have some advise on that also?

Thanks.

Elliot Garbus

unread,
Jan 28, 2021, 4:31:14 PM1/28/21
to kivy-...@googlegroups.com

I have not done any game programming – so take this with a grain of salt.

The consideration of using a database (as single file) or 400 separate text files has more to do with operational concerns that with programming concerns.

  • If you want to update the game with new levels – will it be easier to update using one file – or distributing 400 or more?
  • If you have additional data to save (users, game state…) would you save it in a data base – or a set of files.
  • I could imagine evolving the game engine so it gets the number of levels from the database, making it more flexible and dynamic.

 

There are other alternatives as well, you could combine all of your maps into one JSON file, or use a zip file to contain all of the maps into one file.

I have created a number of music pass that have a “database” of user content.  It was easy to just manage this as a JSON file.

 

Given you already know some sql, if you see any benefits to moving to a single file – SQLite seems like a good choice.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/76b56fef-7b68-4462-b7ba-071cca31360ao%40googlegroups.com.

 

Daniel Leal

unread,
Jan 28, 2021, 5:05:45 PM1/28/21
to Kivy users support
Thank you!

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages