Skip to content

Commit 51be932

Browse files
updated persistance talk
1 parent bc1b378 commit 51be932

File tree

4 files changed

+62
-13
lines changed

4 files changed

+62
-13
lines changed

_downloads/add_book_data.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
sample data for persistence/serializatiion examples
5+
6+
This version is nested, with more stucture
7+
- can be saved with pickle, JSON, xml...
8+
"""
9+
10+
AddressBook = [ {'first_name': "Chris",
11+
'last_name': "Barker",
12+
'address' : {'line_1':"835 NE 33rd St",
13+
'line_2' : "",
14+
'city' : "Seattle",
15+
'state': "WA",
16+
'zip': "96543"},
17+
'email' : "PythonCHB@gmail.com",
18+
'home_phone' : "206-555-1234",
19+
'office_phone' : "123-456-7890",
20+
'cell_phone' : "234-567-8901",
21+
},
22+
23+
{'first_name': "Fred",
24+
'last_name': "Jones",
25+
'address' : {'line_1':"123 SE 13th St",
26+
'line_2' : "Apt. 43",
27+
'city' : "Tacoma",
28+
'state': "WA",
29+
'zip': "93465"},
30+
'email' : "FredJones@some_company.com",
31+
'home_phone' : "510-555-1234",
32+
'office_phone' : "564-466-7990",
33+
'cell_phone' : "403-561-8911",
34+
},
35+
36+
{'first_name': "Nancy",
37+
'last_name': "Wilson",
38+
'address' : {'line_1':"8654 Walnut St",
39+
'line_2' : "Suite 567",
40+
'city' : "Pasadena",
41+
'state': "CA",
42+
'zip': "12345"},
43+
'email' : "Wilson.Nancy@gmail.com",
44+
'home_phone' : "423-321-9876",
45+
'office_phone' : "123-765-9877",
46+
'cell_phone' : "432-567-8466",
47+
},
48+
]
49+

_sources/persistance_serialization.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ http://docs.python.org/library/shelve.html
178178
LAB
179179
---
180180

181-
There are two datasets in the ``Examples\Session10`` dir:
181+
Here are two datasets embedded in Python:
182182

183-
.. code-block:: ipython
183+
:download:`address book data <../code/persistance/add_book_data.py>`
184+
:download:`flat address book data <../code/persistance/add_book_data.py>`
185+
186+
They can be loaded with::
184187

185-
add_book_data.py
186-
add_book_data_flat.py
187-
# load with:
188188
from add_book_data import AddressBook
189189

190190
They have address book data -- one with a nested dict, one "flat"
@@ -587,7 +587,7 @@ Support for a large number of third-party Database drivers:
587587
* PostgreSQL
588588
* Oracle
589589
* MSSQL (?)
590-
* .....
590+
* ...
591591

592592
http://www.python.org/dev/peps/pep-0249}
593593

persistance_serialization.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ <h2>Shelve<a class="headerlink" href="#shelve" title="Permalink to this headline
262262
</div>
263263
<div class="section" id="lab">
264264
<h2>LAB<a class="headerlink" href="#lab" title="Permalink to this headline"></a></h2>
265-
<p>There are two datasets in the <code class="docutils literal"><span class="pre">Examples\Session10</span></code> dir:</p>
266-
<div class="highlight-ipython"><div class="highlight"><pre><span class="n">add_book_data</span><span class="o">.</span><span class="n">py</span>
267-
<span class="n">add_book_data_flat</span><span class="o">.</span><span class="n">py</span>
268-
<span class="c"># load with:</span>
269-
<span class="kn">from</span> <span class="nn">add_book_data</span> <span class="kn">import</span> <span class="n">AddressBook</span>
265+
<p>Here are two datasets embedded in Python:</p>
266+
<p><a class="reference download internal" href="_downloads/add_book_data.py"><code class="xref download docutils literal"><span class="pre">address</span> <span class="pre">book</span> <span class="pre">data</span></code></a>
267+
<a class="reference download internal" href="_downloads/add_book_data.py"><code class="xref download docutils literal"><span class="pre">flat</span> <span class="pre">address</span> <span class="pre">book</span> <span class="pre">data</span></code></a></p>
268+
<p>They can be loaded with:</p>
269+
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">add_book_data</span> <span class="kn">import</span> <span class="n">AddressBook</span>
270270
</pre></div>
271271
</div>
272272
<p>They have address book data &#8211; one with a nested dict, one &#8220;flat&#8221;</p>
@@ -576,7 +576,7 @@ <h2>DB-API<a class="headerlink" href="#db-api" title="Permalink to this headline
576576
<li>PostgreSQL</li>
577577
<li>Oracle</li>
578578
<li>MSSQL (?)</li>
579-
<li></li>
579+
<li>...</li>
580580
</ul>
581581
</div></blockquote>
582582
<p><a class="reference external" href="http://www.python.org/dev/peps/pep-0249">http://www.python.org/dev/peps/pep-0249</a>}</p>

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)