You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
or <ahref="https://pypi.python.org/pypi/MySQL-python/1.2.5">MySQL-python</a> (for
3330
+
MySQL). Take a look at the table below which shows how ORMs can work with
3331
+
different web frameworks and connectors and relational databases.</p>
3332
+
<p><imgsrc="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>
3333
+
<p>The above table shows for example that SQLAlchemy can work with varying
3334
+
web frameworks and database connectors. Developers can also use ORMs without
3335
+
a web framework, such as when creating a data analysis tool or a batch
3336
+
script without a user interface.</p>
3295
3337
<h2>What are the downsides of using an ORM?</h2>
3296
3338
<p>There are numerous downsides of ORMs, including</p>
3297
3339
<ol>
3298
-
<li>impedance mismatch</li>
3299
-
<li>difficulty writing complex queries</li>
3300
-
<li>potential for reduced performance</li>
3301
-
<li>shifting complexity into the application from the database layer</li>
3340
+
<li>Impedance mismatch</li>
3341
+
<li>Potential for reduced performance</li>
3342
+
<li>Shifting complexity from the database into the application code</li>
3302
3343
</ol>
3303
-
<h2>Django's ORM</h2>
3304
-
<p>The <ahref="/django.html">Django</a> web framework comes with its own built-in
3305
-
object-relational mapping module, generally referred to as "the Django ORM".</p>
3344
+
<h3>Impedance mismatch</h3>
3345
+
<p>The phrase "impedance mismatch" is commonly used in conjunction with ORMs.
3346
+
Impedance mismatch is a catch-all term for the difficulties that occur when
3347
+
moving data between relational tables and application objects. The gist
3348
+
is that the way a developer uses objects is different from how data is
3349
+
stored and joined in relational tables.</p>
3350
+
<p><ahref="http://www.agiledata.org/essays/impedanceMismatch.html">This article on ORM impedance mismatch</a>
3351
+
does a solid job of explaing what the concept is at a high level and
3352
+
provides diagrams to visualize why the problem occurs.</p>
3353
+
<h3>Potential for reduced performance</h3>
3354
+
<p>One of the concerns that's associated with any higher-level abstraction or
3355
+
framework is potential for reduced performance. With ORMs, the performance
3356
+
hit comes from the translation of application code into a corresponding SQL
3357
+
statement which may not be tuned properly.</p>
3358
+
<p>ORMs are also often easy to try but difficult to master. For example, a
<ahref="https://peewee.readthedocs.org/en/latest/">Peewee ORM</a> instead of
3471
3575
SQLAlchemy for the blog back end.</p>
3472
3576
</li>
3577
+
</ul>
3578
+
<h3>Pony ORM resources</h3>
3579
+
<ul>
3580
+
<li>
3581
+
<p><ahref="http://jakeaustwick.me/why-you-should-give-ponyorm-a-chance/">Why you should give Pony ORM a chance</a>
3582
+
explains some of the benefits of Pony ORM that make it worth trying out.</p>
3583
+
</li>
3584
+
<li>
3585
+
<p><ahref="http://www.blog.pythonlibrary.org/2014/07/21/python-101-an-intro-to-pony-orm/">An intro to Pony ORM</a>
3586
+
shows the basics of how to use the library, such as creating databases
3587
+
and manipulating data.</p>
3588
+
</li>
3589
+
<li>
3590
+
<p>The Pony ORM author explains on a Stack Overflow answer
3591
+
<ahref="http://stackoverflow.com/questions/16115713/how-pony-orm-does-its-tricks">how Pony ORM works behind the scenes</a>.
3592
+
Worth a read whether or not you're using the ORM just to find out how
3593
+
some of the magic coding works.</p>
3594
+
</li>
3595
+
</ul>
3596
+
<h3>SQLObject resources</h3>
3597
+
<ul>
3598
+
<li>
3599
+
<p>This post on
3600
+
<ahref="http://www.andypatterns.com/index.php/blog/object_relational_mapping_pattern_-_using_sqlobj/">Object-Relational Mapping with SQLObject</a>
3601
+
explains the concept behind ORMs and shows the Python code for how they
3602
+
can be used.</p>
3603
+
</li>
3604
+
<li>
3605
+
<p>Ian Bicking presented on SQLObject back in 2004 with a talk on
3606
+
<ahref="http://www.ianbicking.org/docs/sqlobject-presentation/sqlobject-and-database-programming.html">SQLObject and Database Programming in Python</a>.</p>
3607
+
</li>
3473
3608
</ul>
3474
3609
<h1>Application Programming Interfaces</h1>
3475
3610
<p>Application programming interfaces (APIs) provide machine-readable
@@ -6273,6 +6408,9 @@ <h1>Change Log</h1>
6273
6408
<h2>2015</h2>
6274
6409
<h3>June</h3>
6275
6410
<ul>
6411
+
<li>Nice little update to the <ahref="/object-relational-mappers-orms.html">ORMs page</a>
6412
+
with a diagram showing that different ORMs can work with varying
6413
+
web frameworks and backends.</li>
6276
6414
<li>Added a new section just for Nginx resources and Removed broken links on
6277
6415
the <ahref="/web-servers.html">web servers</a> page.</li>
0 commit comments