Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may find that <code>pickle</code> and databases don't work too well together.</p> <p>Python's <a href="http://docs.python.org/library/pickle.html" rel="nofollow">pickle</a> is for serializing Python objects to a format, that can then be read back in to Python objects by Python. Although it's very easy to serialize with <code>pickle</code>, you can't* query this serialized format, you can't* read it into a program in another language. Check out <a href="http://docs.python.org/library/pickle.html#module-cPickle" rel="nofollow">cPickle</a>, another Python module, for faster <code>pickle</code>-ing.</p> <p>Databases, on the other hand, are great for persisting data <em>in such a way that it is queryable and non-language-specific</em>. But the cost is that it's generally harder to get/put data into/from the database. That's why there's special tools like <a href="http://www.sqlalchemy.org/" rel="nofollow">SQL Alchemy</a>, and endless blog-based debates about the benefits/horrors of Object-Relation-Mapping software.</p> <p><code>Pickle</code>-ing objects, and then sending them to a database such as MySQL or SQL Server is probably not a good idea. However, check out <a href="http://docs.python.org/library/shelve.html#module-shelve" rel="nofollow">shelve</a>, another Python module for database-like persistence of Python objects.</p> <p>So, to sum up:</p> <ul> <li>use <code>pickle</code> or <code>shelve</code> if you just need to save the data for later use by a Python program</li> <li>map objects to a database if you want to persist the data for general use, with the understanding that this requires more effort</li> <li>performance-wise, <code>cPickle</code> will probably win over a database + object/relation mapping</li> </ul> <hr> <p>*: at least, not without a lot of effort and/or special libraries.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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