Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Most importantly, unless you specifically need performance or high reliability, do whatever will make your code simplest/easiest to write.</p> <hr> <p>If your data is extremely structured (and you know SQL or are willing to learn) then using a database like <code>sqlite3</code> might be appropriate. (You should ignore the comment about database size and RAM: there are times when databases are appropriate for even very small data sets, because of how the data is structured.)</p> <p>If the data is relatively simple and you don't need the reliability that a database (normally) has then storing it in one of the builtin datatypes while the program is running is probably fine.</p> <p>If you'd like the data stored on disk to be human readable (and editable, with a bit of effort), then a format like JSON (there is builtin <code>json</code> module) is nice, since the basic Python objects serialise without any effort. If the data not so simple then <a href="https://en.wikipedia.org/wiki/YAML" rel="noreferrer">YAML</a> is essentially an extended version of JSON (<a href="http://pyyaml.org/" rel="noreferrer">PyYAML</a> is very good.). Similarly, you could use CSV files (the <code>csv</code> modules), although this is not nearly as good as JSON or YAML, or just a custom text format (but this is quite a lot of effort to get error handling and so on implemented neatly).</p> <p>Finally, if your data contains more advanced objects (e.g. recursive dictionaries, or complicated custom datatypes) then using one of the builtin binary serialisation techniques (<code>pickle</code>, <code>shelve</code> etc.) <em>might</em> be appropriate, however, YAML can handle many of these things (including recursive data structures).</p> <p>Some general points:</p> <ul> <li>Plain text formats are nice, as they allow values to be tweaked easily and debugging/testing is easy</li> <li>Binary formats are nice, as they mean that values can't be tweaked without a little bit of extra effort (this is not saying they can't be adjusted though), and the file size is smaller (probably not relevant)</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload