Python Forum

Full Version: Newbie Start with Text or Table?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm totally new. Going to write a little thing to keep one or two hundred strings maybe 250 chars long is all.

Better to write them to a text file or better to get straight into tables in mysql or such?
what you store your data as is very much dependent on what you plan to do with it after it is stored.

What is in the text? is it formatted in such a way that it can be retrieved by key?

Other formats may be appropriate, such as JSON file.

Show some sample data.
You don't need a program to do that. Writing a text file sounds perfect.
It's a little game for my small son. So I do need a program.

Essentially he wants to write in questions and get back random answers.

Nonsense is fine. He found something like this on the web and wants to do it himself, have the control to put in his own text.

well they might not be questions even so that it becomes a fake nonsense 'conversation'.
You could perhaps try TinyDB for this persistence use case. Its usage is straightforward.
To keep it simple for adding new strings and editing strings, I'd go ahead and use a text file, then read the strings in and pick random strings to display.

Other methods are fine and certainly have advantages. But, they will require you to write a "maintenance" section where you add and edit the strings. Text file avoids that as you can use Notepad or similar to make the modifications and use your program for the interaction.