forked from mattmakai/fullstackpython.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject-relational-mappers-orms.html
531 lines (525 loc) · 35 KB
/
object-relational-mappers-orms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Matt Makai">
<meta name="description" content="Object-relational mappers (ORMs) provide a bridge between relational databases and object-oriented code. Learn about ORMs on Full Stack Python.">
<link rel="shortcut icon" href="theme/img/fsp-fav.png">
<title>Object-relational Mappers (ORMs) - Full Stack Python</title>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<link href="theme/css/f.min.css" rel="stylesheet">
</head>
<body>
<div style="padding: 0 0 20px 0; margin: 0 0 20px 0; background-color: #22B24C;">
<div class="container">
<h2 style="color: #fff; margin: 20px 40px 0 0;"><a href="https://www.gumroad.com/l/python-deployments" style="color: #fff">The Full Stack Python Guide to Deployments book</a> has been released!</h2>
</div>
</div> <a href="https://github.com/makaimc/fullstackpython.com"><img style="position: absolute; top: 0; right: 0; border: 0;" src="/theme/img/fork.png" alt="Fork me on GitHub"></a>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="logo-header-section">
<a href="/" style="text-decoration: none; border: none;"><img src="theme/img/fsp-logo.png" height="52" width="52" class="logo-image" style="padding-top: 1px;" alt="Full Stack Python logo"></a>
<span class="logo-title"><a href="/">Full Stack Python</a></span>
</div>
</div>
</div><div class="row">
<div class="col-md-8">
<h1>Object-relational mappers (ORMs)</h1>
<p>An object-relational mapper (ORM) is a code library that automates the
transfer of data stored in relational databases tables into objects that
are more commonly used in application code.</p>
<h2>Why are ORMs useful?</h2>
<p>ORMs provide a high-level abstraction upon a
<a href="/databases.html">relational database</a> that allows a developer to write
Python code instead of SQL to create, read, update and delete data and
schemas in their database. Developers can use the programming language they
are comfortable with to work with a database instead of writing SQL
statements or stored procedures.</p>
<p>For example, without an ORM a developer would write the following SQL
statement to retrieve every row in the USERS table where the
<code>zip_code</code> column is 94107:</p>
<div class="highlight"><pre>SELECT * FROM USERS WHERE zip_code=94107;
</pre></div>
<p>The equivalent Django ORM query would instead look like the following Python
code:</p>
<div class="highlight"><pre># obtain everyone in the 94107 zip code and assign to users variable
users = Users.objects.filter(zip_code=94107)
</pre></div>
<p>The ability to write Python code instead of SQL can speed up web application
development, especially at the beginning of a project. The potential
development speed boost comes from not having to switch from Python code
into writing declarative paradigm SQL statements. While some software
developers may not mind switching back and forth between languages, it's
typically easier to knock out a prototype or start a web application using
a single programming language.</p>
<p>ORMs also make it theoretically possible to switch an application between
various relational databases. For example, a developer could use SQLite for
local development and MySQL in production. A production application could
be switched from MySQL to PostgreSQL with minimal code modifications.</p>
<p>In reality however, it's best to use the same database for local development
as is used in production. Otherwise unexpected errors could hit in production
that were not seen in a local development environment. Also, it's rare that
a project would switch from one database in production to another one unless
there was a pressing reason.</p>
<div class="well see-also">
While you're learning about ORMs you should also read up on
<a href="/deployment.html">deployment</a> and check out the
<a href="/application-dependencies.html">application dependencies</a> page.
</div>
<h2>Do I have to use an ORM for my web application?</h2>
<p>Python ORM libraries are not required for accessing relational
databases. In fact, the low-level access is typically provided by another
library called a <em>database connector</em>, such as
<a href="http://initd.org/psycopg/">psycopg</a> (for PostgreSQL)
or <a href="https://pypi.python.org/pypi/MySQL-python/1.2.5">MySQL-python</a> (for
MySQL). Take a look at the table below which shows how ORMs can work with
different web frameworks and connectors and relational databases.</p>
<p><img src="theme/img/orm-examples.png" width="100%" alt="Examples of how varying Python ORMs can work with different connectors and backends." class="technical-diagram" /></p>
<p>The above table shows for example that SQLAlchemy can work with varying
web frameworks and database connectors. Developers can also use ORMs without
a web framework, such as when creating a data analysis tool or a batch
script without a user interface.</p>
<h2>What are the downsides of using an ORM?</h2>
<p>There are numerous downsides of ORMs, including</p>
<ol>
<li>Impedance mismatch</li>
<li>Potential for reduced performance</li>
<li>Shifting complexity from the database into the application code</li>
</ol>
<h3>Impedance mismatch</h3>
<p>The phrase "impedance mismatch" is commonly used in conjunction with ORMs.
Impedance mismatch is a catch-all term for the difficulties that occur when
moving data between relational tables and application objects. The gist
is that the way a developer uses objects is different from how data is
stored and joined in relational tables.</p>
<p><a href="http://www.agiledata.org/essays/impedanceMismatch.html">This article on ORM impedance mismatch</a>
does a solid job of explaing what the concept is at a high level and
provides diagrams to visualize why the problem occurs.</p>
<h3>Potential for reduced performance</h3>
<p>One of the concerns that's associated with any higher-level abstraction or
framework is potential for reduced performance. With ORMs, the performance
hit comes from the translation of application code into a corresponding SQL
statement which may not be tuned properly.</p>
<p>ORMs are also often easy to try but difficult to master. For example, a
beginner using Django might not know about the
<a href="https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-related"><code>select_related()</code> function</a>
and how it can improve some queries' foreign key relationship performance.
There are dozens of performance tips and tricks for every ORM. It's possible
that investing time in learning those quirks may be better spent just
learning SQL and how to write stored procedures.</p>
<p>There's a lot of hand-waving "may or may not" and "potential for" in this
section. In large projects ORMs are good enough for roughly 80-90% of use
cases but in 10-20% of a project's database interactions there can be
major performance improvements by having a knowledgeable database
administrator write tuned SQL statements to replace the ORM's generated
SQL code.</p>
<h3>Shifting complexity from the database into the app code</h3>
<p>The code for working with an application's data has to live somewhere. Before
ORMs were common, database stored procedures were used to encapsulate the
database logic. With an ORM, the data manipulation code instead lives within
the application's Python codebase. The addition of data handling logic in the
codebase generally isn't an issue with a sound application design, but it does
increase the total amount of Python code instead of splitting code between
the application and the database stored procedures.</p>
<h2>Python ORM Implementations</h2>
<p>There are numerous ORM implementations written in Python, including</p>
<ol>
<li><a href="https://docs.djangoproject.com/en/1.8/topics/db/">The Django ORM</a></li>
<li><a href="http://www.sqlalchemy.org/">SQLAlchemy</a></li>
<li><a href="https://peewee.readthedocs.org/en/latest/">Peewee</a></li>
<li><a href="http://ponyorm.com/">PonyORM</a></li>
<li><a href="http://sqlobject.org/">SQLObject</a></li>
</ol>
<p>There are other ORMs, such as Canonical's
<a href="https://storm.canonical.com/">Storm</a>, but most of them do not appear to
currently be under active development. Learn more about the major active
ORMs below.</p>
<h3>Django's ORM</h3>
<p>The <a href="/django.html">Django</a> web framework comes with
its own built-in object-relational mapping module, generally referred to
as "the Django ORM" or "Django's ORM".</p>
<p><a href="https://docs.djangoproject.com/en/dev/topics/db/">Django's ORM</a> works well
for simple and medium-complexity database operations. However, there are often
complaints that the ORM makes complex queries much more complicated than
writing straight SQL or using <a href="http://www.sqlalchemy.org/">SQLAlchemy</a>.</p>
<p>It's technically possible to drop down to SQL but it ties the queries to a
specific database implementation. The ORM is coupled closely with Django so
replacing the default ORM with SQLAlchemy is currently a hack workaround. Note
though that some of the Django core committers believe it is only a matter of
time before the default ORM is replaced with SQLAlchemy. It will be a large
effort to get that working though so it's likely to come in
<a href="https://github.com/makaimc/fullstackpython.com/issues/48">Django 1.9 or later</a>.</p>
<p>Since the majority of Django projects are tied to the default ORM, it's best to
read up on advanced use cases and tools for doing your best work within the
existing framework.</p>
<h3>SQLAlchemy</h3>
<p><a href="http://www.sqlalchemy.org/">SQLAlchemy</a> is a well-regarded
Python ORM because it gets the abstraction level "just right" and
seems to make complex database queries easier to write than the Django
ORM in most cases. SQLAlchemy is typically used with Flask as the database
ORM via the <a href="https://pythonhosted.org/Flask-SQLAlchemy/">Flask-SQLAlchemy</a>
extension.</p>
<h3>Peewee</h3>
<p><a href="https://peewee.readthedocs.org/en/latest/">Peewee</a> is a Python ORM
written to be
"<a href="http://charlesleifer.com/blog/the-case-for-peewee-small-hackable-and-fun/">simpler, smaller and more hackable</a>"
than SQLAlchemy. The analogy used by the core Peewee author is that Peewee
is to SQLAlchemy as SQLite is to PostgreSQL. An ORM does not have to work
for every exhaustive use case in order to be useful.</p>
<h3>Pony</h3>
<p><a href="http://ponyorm.com/">Pony ORM</a> is another Python ORM with a slight twist in
its licensing model. The project is multi-licensed. Pony is free for use
on open source projects but has a
<a href="http://ponyorm.com/license-and-pricing.html">commercial license</a> that
is required for commercial projects. The license is a one-time payment
and does not necessitate a recurring fee.</p>
<h3>SQLObject</h3>
<p><a href="http://sqlobject.org/">SQLObject</a> is an ORM that has been under active
open source development since
<a href="http://sqlobject.org/News1.html#sqlobject-0-5">before 2003</a>.</p>
<h2>Schema migrations</h2>
<p>Schema migrations, for example when you need to add a new column to an
existing table in your database, are not technically part of ORMs. However,
since ORMs typically lead to a hands-off approach to the database (at the
developers peril in many cases), libraries to perform schema migrations
often go hand-in-hand with Python ORM usage on web application projects.</p>
<p>Database schema migrations are a complex topic and deserve their own page.
For now, we'll lump schema migration resources under ORM links below.</p>
<h3>General ORM resources</h3>
<ul>
<li>
<p>There's also a detailed overview of <a href="http://www.agiledata.org/essays/mappingObjects.html">what ORMs are</a>
on another page of the website.</p>
</li>
<li>
<p>This <a href="https://github.com/sloria/PythonORMSleepy">example GitHub project</a>
implements the same Flask application with several different ORMs:
SQLAlchemy, Peewee, MongoEngine, stdnet and PonyORM.</p>
</li>
<li>
<p>Martin Fowler addresses the
<a href="http://martinfowler.com/bliki/OrmHate.html">ORM hate</a>
in an essay about how ORMs are often misused but that they do provide
benefits to developers.</p>
</li>
<li>
<p>If you're confused about the difference between a connector, such as
MySQL-python and an ORM like SQLAlchemy, read this
<a href="http://stackoverflow.com/questions/2550292/purpose-of-sqlalchemy-over-mysqldb">StackOverflow answer</a>
on the topic.</p>
</li>
</ul>
<h3>Django ORM resources</h3>
<ul>
<li>
<p><a href="http://www.dabapps.com/blog/django-models-and-encapsulation/">Django models, encapsulation and data integrity</a>
is a detailed article by Tom Christie on encapsulating Django models for
data integrity.</p>
</li>
<li>
<p><a href="http://django-debug-toolbar.readthedocs.org/en/1.2/">Django Debug Toolbar</a>
is a powerful Django ORM database query inspection tool. Highly recommended
during development to ensure you're writing reasonable query code.
<a href="http://mtford.co.uk/blog/2/">Django Silk</a> is another inspection tool and
has capabilities to do more than just SQL inspection.</p>
</li>
<li>
<p><a href="http://reinout.vanrees.org/weblog/2014/05/06/making-faster.html">Making a specific Django app faster</a>
is a Django performance blog post with some tips on measuring performance
and optimizing based on the measured results.</p>
</li>
<li>
<p><a href="https://speakerdeck.com/alex/why-i-hate-the-django-orm">Why I Hate the Django ORM</a>
is Alex Gaynor's overview of the bad designs decisions, some of which he
made, while building the Django ORM.</p>
</li>
<li>
<p><a href="https://speakerdeck.com/craigkerstiens/going-beyond-django-orm-with-postgres">Going Beyond Django ORM with Postgres</a>
is specific to using PostgreSQL with Django.</p>
</li>
<li>
<p><a href="http://www.calazan.com/migrating-django-app-from-mysql-to-postgresql/">Migrating a Django app from MySQL to PostgreSQL</a>
is a quick look at how to move from MySQL to PostgreSQL. However, my guess
is that any Django app that's been running for awhile on one
<a href="/databases.html">relational database</a> will require a lot more work to
port over to another backend even with the power of the ORM.</p>
</li>
<li>
<p><a href="http://blog.kevinastone.com/django-model-descriptors.html">Django Model Descriptors</a>
discusses and shows how to incorporate business logic into Django models
to reduce complexity from the views and make the code easier to reuse across
separate views.</p>
</li>
<li>
<p><a href="http://treyhunner.com/2014/03/migrating-to-django-1-dot-7/">Supporting both Django 1.7 and South</a>
explains the difficulty of supporting Django 1.7 and maintaining South
migrations for Django 1.6 then goes into how it can be done.</p>
</li>
<li>
<p><a href="https://www.calazan.com/adding-basic-search-to-your-django-site/">Adding basic search to your Django site</a>
shows how to write generic queries that'll allow you to provide site
search via the Django ORM without relying on another tool like
ElasticSearch. This is great for small sites before you scale them up with
a more robust search engine.</p>
</li>
<li>
<p><a href="https://www.wellfireinteractive.com/blog/using-django-proxy-models">How to use Django's Proxy Models</a>
is a solid post on a Django ORM concept that doesn't frequently get a lot
of love or explanation.</p>
</li>
<li>
<p><a href="http://tech.marksblogg.com/django-admin-logins.html">Tightening Django Admin Logins</a>
shows you how to log authentication failures, create an IP addresses white
list and combine fail2ban with the authentication failures list.</p>
</li>
<li>
<p><a href="https://realpython.com/blog/python/django-migrations-a-primer/">Django Migrations - a Primer</a>
takes you through the new migrations system integrated in the Django core as of Django 1.7, looking specifically at a solid workflow that you can use for creating and applying migrations.</p>
</li>
<li>
<p><a href="https://markusholtermann.eu/2014/09/django-17-database-migrations-done-right/">Django 1.7: Database Migrations Done Right</a>
explains why South was not directly integrated into Django, how migrations
are built and shows how backwards migrations work.</p>
</li>
<li>
<p><a href="http://www.rkblog.rk.edu.pl/w/p/squashing-and-optimizing-migrations-django/">Squashing and optimizing migrations in Django</a>
shows a simple example with code for how to use the migrations integrated
into Django 1.7.</p>
</li>
</ul>
<h3>SQLAlchemy resources</h3>
<ul>
<li>
<p>If you're interested in the differences between SQLAlchemy and the Django
ORM I recommend reading
<a href="http://lucumr.pocoo.org/2011/7/19/sqlachemy-and-you/">SQLAlchemy and You</a>
by Armin Ronacher.</p>
</li>
<li>
<p>There is an entire chapter in the
<a href="http://aosabook.org/en/sqlalchemy.html">Architecture of Open Source Applications book on SQLAlchemy </a>.
The content is detailed and well worth reading to understand what's
happening under the covers.</p>
</li>
<li>
<p><a href="http://www.pythoncentral.io/sqlalchemy-vs-orms/">SQLAlchemy vs Other ORMs</a>
provides a detailed comparison of SQLAlchemy against alternatives.</p>
</li>
<li>
<p>Most Flask developers use SQLAlchemy as an ORM to relational databases.
If you're unfamiliar with SQLAlchemy questions will often come up such as
<a href="http://stackoverflow.com/questions/4201455/sqlalchemy-whats-the-difference-between-flush-and-commit">what's the difference between flush and commit?</a>
that are important to understand as you build out your app.</p>
</li>
</ul>
<h3>Peewee resources</h3>
<ul>
<li>
<p><a href="http://charlesleifer.com/blog/managing-database-connections-with-peewee/">Managing database connections with Peewee</a>
explains the connection pool and ExecutionContext of the ORM.</p>
</li>
<li>
<p><a href="http://charlesleifer.com/blog/dear-diary-an-encrypted-command-line-diary-with-python/">An encrypted command-line diary with Python</a>
is an awesome walkthrough explaining how to use SQLite, SQLCipher and
Peewee to create an encrypted file with your contents, diary or otherwise.</p>
</li>
<li>
<p>The <a href="http://docs.peewee-orm.com/en/latest/peewee/quickstart.html">official Peewee quickstart documentation</a>
along with the
<a href="http://docs.peewee-orm.com/en/latest/peewee/example.html">example Twitter clone app</a>
will walk you through the ins and outs of your first couple Peewee-powered
projects.</p>
</li>
<li>
<p><a href="http://charlesleifer.com/blog/shortcomings-in-the-django-orm-and-a-look-at-peewee-a-lightweight-alternative/">Shortcomings in the Django ORM and a look at Peewee</a>
from the author of the Peewee ORM explains how some of the design
decisions made in Peewee were in reaction to parts of the Django ORM
that didn't work so well in practice.</p>
</li>
<li>
<p><a href="http://charlesleifer.com/blog/how-to-make-a-flask-blog-in-one-hour-or-less/">How to make a Flask blog in one hour or less</a>
is a well written tutorial that uses the
<a href="https://peewee.readthedocs.org/en/latest/">Peewee ORM</a> instead of
SQLAlchemy for the blog back end.</p>
</li>
</ul>
<h3>Pony ORM resources</h3>
<ul>
<li>
<p><a href="http://jakeaustwick.me/why-you-should-give-ponyorm-a-chance/">Why you should give Pony ORM a chance</a>
explains some of the benefits of Pony ORM that make it worth trying out.</p>
</li>
<li>
<p><a href="http://www.blog.pythonlibrary.org/2014/07/21/python-101-an-intro-to-pony-orm/">An intro to Pony ORM</a>
shows the basics of how to use the library, such as creating databases
and manipulating data.</p>
</li>
<li>
<p>The Pony ORM author explains on a Stack Overflow answer
<a href="http://stackoverflow.com/questions/16115713/how-pony-orm-does-its-tricks">how Pony ORM works behind the scenes</a>.
Worth a read whether or not you're using the ORM just to find out how
some of the magic coding works.</p>
</li>
</ul>
<h3>SQLObject resources</h3>
<ul>
<li>
<p>This post on
<a href="http://www.andypatterns.com/index.php/blog/object_relational_mapping_pattern_-_using_sqlobj/">Object-Relational Mapping with SQLObject</a>
explains the concept behind ORMs and shows the Python code for how they
can be used.</p>
</li>
<li>
<p>Ian Bicking presented on SQLObject back in 2004 with a talk on
<a href="http://www.ianbicking.org/docs/sqlobject-presentation/sqlobject-and-database-programming.html">SQLObject and Database Programming in Python</a>.</p>
</li>
</ul>
<h3>What would you like to learn about building Python web apps?</h3>
<div class="row">
<div class="col-md-4">
<div class="well select-next">
<a href="/databases.html" class="btn btn-success btn-full"><svg width="28" height="30" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1168 1216q0 33-23.5 56.5t-56.5 23.5-56.5-23.5-23.5-56.5 23.5-56.5 56.5-23.5 56.5 23.5 23.5 56.5zm256 0q0 33-23.5 56.5t-56.5 23.5-56.5-23.5-23.5-56.5 23.5-56.5 56.5-23.5 56.5 23.5 23.5 56.5zm112 160v-320q0-13-9.5-22.5t-22.5-9.5h-1216q-13 0-22.5 9.5t-9.5 22.5v320q0 13 9.5 22.5t22.5 9.5h1216q13 0 22.5-9.5t9.5-22.5zm-1230-480h1180l-157-482q-4-13-16-21.5t-26-8.5h-782q-14 0-26 8.5t-16 21.5zm1358 160v320q0 66-47 113t-113 47h-1216q-66 0-113-47t-47-113v-320q0-25 16-75l197-606q17-53 63-86t101-33h782q55 0 101 33t63 86l197 606q16 50 16 75z" fill="#fff"/></svg></a>
<p class="under-btn">Tell me about standard relational databases.</p> </div>
</div>
<div class="col-md-4">
<div class="well select-next">
<a href="/no-sql-datastore.html" class="btn btn-success btn-full"><svg width="34" height="30" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1151 960h316q-1-3-2.5-8t-2.5-8l-212-496h-708l-212 496q-1 2-2.5 8t-2.5 8h316l95 192h320zm513 30v482q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-482q0-62 25-123l238-552q10-25 36.5-42t52.5-17h832q26 0 52.5 17t36.5 42l238 552q25 61 25 123z" fill="#fff"/></svg></a>
<p class="under-btn">What're these NoSQL data stores hipster developers keep talking about?</p> </div>
</div>
<div class="col-md-4">
<div class="well select-next">
<a href="/data.html" class="btn btn-success btn-full"><svg width="28" height="30" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M63 1536h-63v-1408h63v1408zm63-1h-32v-1407h32v1407zm94 0h-31v-1407h31v1407zm157 0h-31v-1407h31v1407zm157 0h-62v-1407h62v1407zm126 0h-31v-1407h31v1407zm63 0h-31v-1407h31v1407zm63 0h-31v-1407h31v1407zm157 0h-63v-1407h63v1407zm157 0h-63v-1407h63v1407zm126 0h-63v-1407h63v1407zm126 0h-63v-1407h63v1407zm94 0h-63v-1407h63v1407zm189 0h-94v-1407h94v1407zm63 0h-32v-1407h32v1407zm94 1h-63v-1408h63v1408z" fill="#fff"/></svg></a>
<p class="under-btn">I want to know about working with data in Python.</p> </div>
</div>
</div><div id="mc_embed_signup">
<form action="//mattmakai.us2.list-manage.com/subscribe/post?u=b7e774f0c4f05dcebbfee183d&id=b22335388d" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<h4>Sign up here to receive an email with major updates to this site and Python tutorials delivered to your inbox once a month.</h4>
<div class="row">
<div class="col-md-9">
<input type="email" value="" name="EMAIL" class="email form-control" id="mce-EMAIL" placeholder="email address" required>
<div style="position: absolute; left: -5000px;"><input type="text" name="b_b7e774f0c4f05dcebbfee183d_b22335388d" tabindex="-1" value=""></div>
</div>
<div class="col-md-3">
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn btn-success" style="font-family: 'Helvetica Neue';"></div>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="col-md-offset-1 col-md-3" id="sidebar">
<div class="panel panel-success">
<div class="panel-body">
<a href="http://www.deploypython.com/"><img src="https://static.fullstackpython.com/fsp-deployment-guide.png" alt="The Full Stack Python Guide to Deployments" width="100%"></a>
<p style="font-size: .8em; margin-top: 10px;">Searching for a complete, step-by-step deployment walkthrough? Learn more about <a href="http://www.deploypython.com/">The Full Stack Python Guide to Deployments book</a>.
</p>
</div>
</div> <div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-head"><a href="/table-of-contents.html" style="color: #fff;">Table of Contents</a></h3>
</div>
<div class="list-group">
<a href="/introduction.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Introduction</a>
<a href="/learning-programming.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Learning Programming</a>
<a href="/why-use-python.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Why Use Python?</a>
<a href="/python-2-or-3.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Python 2 or 3?</a>
<a href="/enterprise-python.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Enterprise Python</a>
<a href="/best-python-resources.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Best Python Resources</a>
<a href="/best-python-videos.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Best Python Videos</a>
<a href="/development-environments.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Development Environments</a>
<a href="/vim.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Vim</a>
<a href="/emacs.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Emacs</a>
<a href="/generators.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Generators</a>
<a href="/comprehensions.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Comprehensions</a>
<a href="/web-frameworks.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Frameworks</a>
<a href="/django.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Django</a>
<a href="/flask.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Flask</a>
<a href="/bottle.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Bottle</a>
<a href="/pyramid.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Pyramid</a>
<a href="/morepath.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Morepath</a>
<a href="/other-web-frameworks.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Other Web Frameworks</a>
<a href="/web-design.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Design</a>
<a href="/cascading-style-sheets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Cascading Style Sheets</a>
<a href="/javascript.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>JavaScript</a>
<a href="/websockets.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WebSockets</a>
<a href="/web-application-security.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Application Security</a>
<a href="/static-site-generator.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Site Generator</a>
<a href="/data.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Data</a>
<a href="/databases.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Databases</a>
<a href="/no-sql-datastore.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>NoSQL Data Stores</a>
<a href="/object-relational-mappers-orms.html" class="list-group-item smaller-item active" style='font-family: "Helvetica Neue",sans-serif;'>Object-relational Mappers (ORMs)</a>
<a href="/application-programming-interfaces.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Application Programming Interfaces</a>
<a href="/api-integration.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>API Integration</a>
<a href="/api-creation.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>API Creation</a>
<a href="/deployment.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Deployment</a>
<a href="/servers.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Servers</a>
<a href="/platform-as-a-service.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Platform-as-a-service</a>
<a href="/operating-systems.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Operating Systems</a>
<a href="/web-servers.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Servers</a>
<a href="/wsgi-servers.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>WSGI Servers</a>
<a href="/source-control.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Source Control</a>
<a href="/application-dependencies.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Application Dependencies</a>
<a href="/static-content.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Static Content</a>
<a href="/task-queues.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Task Queues</a>
<a href="/configuration-management.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Configuration Management</a>
<a href="/continuous-integration.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Continuous Integration</a>
<a href="/logging.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Logging</a>
<a href="/monitoring.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Monitoring</a>
<a href="/web-analytics.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Web Analytics</a>
<a href="/docker.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Docker</a>
<a href="/caching.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Caching</a>
<a href="/testing.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Testing</a>
<a href="/unit-testing.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Unit Testing</a>
<a href="/integration-testing.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Integration Testing</a>
<a href="/code-metrics.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Code Metrics</a>
<a href="/debugging.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Debugging</a>
<a href="/what-full-stack-means.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>What "Full Stack" Means</a>
<a href="/change-log.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Change Log</a>
<a href="/future-directions.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>Future Directions</a>
<a href="/about-author.html" class="list-group-item smaller-item " style='font-family: "Helvetica Neue",sans-serif;'>About the Author</a>
</div>
</div>
<div class="panel panel-success">
<div class="panel-body">
<a href="http://www.deploypython.com/"><img src="https://static.fullstackpython.com/fsp-deployment-guide.png" alt="The Full Stack Python Guide to Deployments" width="100%"></a>
<p style="font-size: .8em; margin-top: 10px;">Searching for a complete, step-by-step deployment walkthrough? Learn more about <a href="http://www.deploypython.com/">The Full Stack Python Guide to Deployments book</a>.
</p>
</div>
</div> <div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-head">Object-relational Mappers (ORMs)</h3></div>
<div class="panel-body">
Major updates are tweeted via
<a href="https://twitter.com/fullstackpython">@fullstackpython</a>.
<hr/>
Need more detailed tutorials than you see here?
<a href="http://www.deploypython.com/">Learn more about The Full Stack Python Guide to Deployments book.</a>
</div>
</div>
</div></div>
<hr/>
<div class="footer pull-right">
<a href="http://www.mattmakai.com/" class="underline">Matt Makai</a>
2015
</div>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-19910497-7', 'auto');
ga('send', 'pageview');
</script>
<script type='text/javascript'>
var trackOutboundLink = function(url) { ga('send', 'event', 'outbound', 'click', url, {'hitCallback': function () { document.location = url; } }); }
</script>
</body>
</html>