Skip to content

Commit 9ce41a4

Browse files
committed
added django orm resource
1 parent a2254ea commit 9ce41a4

File tree

4 files changed

+117
-106
lines changed

4 files changed

+117
-106
lines changed

all.html

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3273,19 +3273,19 @@ <h1>Object-relational mappers (ORMs)</h1>
32733273
transfer of data stored in relational databases tables into objects that
32743274
are more commonly used in application code.</p>
32753275
<h2>Why are ORMs useful?</h2>
3276-
<p>ORMs provide a high-level abstraction upon a
3277-
<a href="/databases.html">relational database</a> that allows a developer to write
3276+
<p>ORMs provide a high-level abstraction upon a
3277+
<a href="/databases.html">relational database</a> that allows a developer to write
32783278
Python code instead of SQL to create, read, update and delete data in
32793279
their database. Developers can use the programming language they are
32803280
comfortable with, in our case Python, to work with data and not have to
32813281
write SQL statements or stored procedures.</p>
3282-
<p>However, Python ORM libraries are not required for accessing relational
3283-
databases. In fact, the low-level access is typically provided by another
3282+
<p>However, Python ORM libraries are not required for accessing relational
3283+
databases. In fact, the low-level access is typically provided by another
32843284
library, such as <a href="http://initd.org/psycopg/">psycopg</a> (for PostgreSQL)
3285-
or <a href="https://pypi.python.org/pypi/MySQL-python/1.2.5">MySQL-python</a> (for
3285+
or <a href="https://pypi.python.org/pypi/MySQL-python/1.2.5">MySQL-python</a> (for
32863286
MySQL).</p>
32873287
<p>Developers can also use ORMs without a web framework, such as when
3288-
creating a data analysis tool or a batch script without a user interface. </p>
3288+
creating a data analysis tool or a batch script without a user interface.</p>
32893289
<div class="well see-also">
32903290
While you're learning about ORMs you should also read up on
32913291
<a href="/deployment.html">deployment</a> and check out the
@@ -3301,55 +3301,55 @@ <h2>What are the downsides of using an ORM?</h2>
33013301
<li>shifting complexity into the application from the database layer</li>
33023302
</ol>
33033303
<h2>Django's ORM</h2>
3304-
<p>The <a href="/django.html">Django</a> web framework comes with its own built-in
3304+
<p>The <a href="/django.html">Django</a> web framework comes with its own built-in
33053305
object-relational mapping module, generally referred to as "the Django ORM".</p>
33063306
<p><a href="https://docs.djangoproject.com/en/dev/topics/db/">Django's ORM</a> works well
33073307
for simple and medium-complexity database operations. However, there are often
33083308
complaints that the ORM makes complex queries much more complicated than
3309-
writing straight SQL or using <a href="http://www.sqlalchemy.org/">SQLAlchemy</a>. </p>
3310-
<p>It's technically possible to drop down to SQL but it ties the queries to a
3309+
writing straight SQL or using <a href="http://www.sqlalchemy.org/">SQLAlchemy</a>.</p>
3310+
<p>It's technically possible to drop down to SQL but it ties the queries to a
33113311
specific database implementation. The ORM is coupled closely with Django so
33123312
replacing the default ORM with SQLAlchemy is currently a hack workaround. Note
33133313
though that some of the Django core committers believe it is only a matter of
33143314
time before the default ORM is replaced with SQLAlchemy. It will be a large
3315-
effort to get that working though so it's likely to come in Django 1.9 or
3315+
effort to get that working though so it's likely to come in Django 1.9 or
33163316
later.</p>
33173317
<p>Since the majority of Django projects are tied to the default ORM, it's best to
33183318
read up on advanced use cases and tools for doing your best work within the
33193319
existing framework.</p>
33203320
<h2>SQLAlchemy</h2>
3321-
<p><a href="http://www.sqlalchemy.org/">SQLAlchemy</a> is currently the most respected
3322-
Python ORM because it typically get the abstraction level "just right" and
3323-
seems to make complex database queries easier to write than the Django ORM
3321+
<p><a href="http://www.sqlalchemy.org/">SQLAlchemy</a> is currently the most respected
3322+
Python ORM because it typically get the abstraction level "just right" and
3323+
seems to make complex database queries easier to write than the Django ORM
33243324
in most cases. SQLAlchemy is typically used with Flask as the database ORM
3325-
via the <a href="https://pythonhosted.org/Flask-SQLAlchemy/">Flask-SQLAlchemy</a>
3325+
via the <a href="https://pythonhosted.org/Flask-SQLAlchemy/">Flask-SQLAlchemy</a>
33263326
extension.</p>
33273327
<h2>Peewee</h2>
3328-
<p><a href="https://peewee.readthedocs.org/en/latest/">Peewee</a> is another Python ORM
3329-
written to be
3330-
<a href="http://charlesleifer.com/blog/the-case-for-peewee-small-hackable-and-fun/">simpler, smaller and more hackable</a>
3331-
than SQLAlchemy. The analogy used by the core Peewee author is that Peewee
3332-
is to SQLAlchemy as SQLite is to PostgreSQL. An ORM does not have to work
3328+
<p><a href="https://peewee.readthedocs.org/en/latest/">Peewee</a> is another Python ORM
3329+
written to be
3330+
<a href="http://charlesleifer.com/blog/the-case-for-peewee-small-hackable-and-fun/">simpler, smaller and more hackable</a>
3331+
than SQLAlchemy. The analogy used by the core Peewee author is that Peewee
3332+
is to SQLAlchemy as SQLite is to PostgreSQL. An ORM does not have to work
33333333
for every exhaustive use case in order to be useful.</p>
33343334
<h2>Schema migrations</h2>
33353335
<p>Schema migrations, for example when you need to add a new column to an
33363336
existing table in your database, are not technically part of ORMs. However,
33373337
since ORMs typically lead to a hands-off approach to the database (at the
3338-
developers peril in many cases), libraries to perform schema migrations
3338+
developers peril in many cases), libraries to perform schema migrations
33393339
often go hand-in-hand with Python ORM usage on web application projects.</p>
3340-
<p>Database schema migrations are a complex topic and deserve their own page.
3341-
For now, we'll lump schema migration resources under ORM links below. </p>
3340+
<p>Database schema migrations are a complex topic and deserve their own page.
3341+
For now, we'll lump schema migration resources under ORM links below.</p>
33423342
<h3>General ORM resources</h3>
33433343
<ul>
33443344
<li>
3345-
<p>This article does a solid job of explaing what
3345+
<p>This article does a solid job of explaing what
33463346
<a href="http://www.agiledata.org/essays/impedanceMismatch.html">ORM impedance mismatch</a>
33473347
is at a high level and provides diagrams to visualize why the problem
33483348
occurs. There's also a detailed overview of <a href="http://www.agiledata.org/essays/mappingObjects.html">what ORMs are</a>
33493349
on another page of the website.</p>
33503350
</li>
33513351
<li>
3352-
<p>Martin Fowler addresses the
3352+
<p>Martin Fowler addresses the
33533353
<a href="http://martinfowler.com/bliki/OrmHate.html">ORM hate</a>
33543354
in an essay about how ORMs are often misused but that they do provide
33553355
benefits to developers.</p>
@@ -3363,9 +3363,9 @@ <h3>Django ORM resources</h3>
33633363
data integrity.</p>
33643364
</li>
33653365
<li>
3366-
<p><a href="http://django-debug-toolbar.readthedocs.org/en/1.2/">Django Debug Toolbar</a>
3366+
<p><a href="http://django-debug-toolbar.readthedocs.org/en/1.2/">Django Debug Toolbar</a>
33673367
is a powerful Django ORM database query inspection tool. Highly recommended
3368-
during development to ensure you're writing reasonable query code.
3368+
during development to ensure you're writing reasonable query code.
33693369
<a href="http://mtford.co.uk/blog/2/">Django Silk</a> is another inspection tool and
33703370
has capabilities to do more than just SQL inspection.</p>
33713371
</li>
@@ -3386,8 +3386,8 @@ <h3>Django ORM resources</h3>
33863386
<li>
33873387
<p><a href="http://www.calazan.com/migrating-django-app-from-mysql-to-postgresql/">Migrating a Django app from MySQL to PostgreSQL</a>
33883388
is a quick look at how to move from MySQL to PostgreSQL. However, my guess
3389-
is that any Django app that's been running for awhile on one
3390-
<a href="/databases.html">relational database</a> will require a lot more work to
3389+
is that any Django app that's been running for awhile on one
3390+
<a href="/databases.html">relational database</a> will require a lot more work to
33913391
port over to another backend even with the power of the ORM.</p>
33923392
</li>
33933393
<li>
@@ -3398,13 +3398,13 @@ <h3>Django ORM resources</h3>
33983398
</li>
33993399
<li>
34003400
<p><a href="http://treyhunner.com/2014/03/migrating-to-django-1-dot-7/">Supporting both Django 1.7 and South</a>
3401-
explains the difficulty of supporting Django 1.7 and maintaining South
3401+
explains the difficulty of supporting Django 1.7 and maintaining South
34023402
migrations for Django 1.6 then goes into how it can be done.</p>
34033403
</li>
34043404
<li>
34053405
<p><a href="https://www.calazan.com/adding-basic-search-to-your-django-site/">Adding basic search to your Django site</a>
3406-
shows how to write generic queries that'll allow you to provide site
3407-
search via the Django ORM without relying on another tool like
3406+
shows how to write generic queries that'll allow you to provide site
3407+
search via the Django ORM without relying on another tool like
34083408
ElasticSearch. This is great for small sites before you scale them up with
34093409
a more robust search engine.</p>
34103410
</li>
@@ -3419,6 +3419,10 @@ <h3>Django ORM resources</h3>
34193419
list and combine fail2ban with the authentication failures list.</p>
34203420
</li>
34213421
<li>
3422+
<p><a href="https://realpython.com/blog/python/django-migrations-a-primer/">Django Migrations - a Primer</a>
3423+
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>
3424+
</li>
3425+
<li>
34223426
<p><a href="https://markusholtermann.eu/2014/09/django-17-database-migrations-done-right/">Django 1.7: Database Migrations Done Right</a>
34233427
explains why South was not directly integrated into Django, how migrations
34243428
are built and shows how backwards migrations work.</p>
@@ -3433,7 +3437,7 @@ <h3>SQLAlchemy resources</h3>
34333437
<ul>
34343438
<li>
34353439
<p>If you're interested in the differences between SQLAlchemy and the Django
3436-
ORM I highly recommend reading
3440+
ORM I highly recommend reading
34373441
<a href="http://lucumr.pocoo.org/2011/7/19/sqlachemy-and-you/">SQLAlchemy and You</a>
34383442
by Armin Ronacher.</p>
34393443
</li>
@@ -3456,14 +3460,14 @@ <h3>Peewee resources</h3>
34563460
</li>
34573461
<li>
34583462
<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>
3459-
from the author of the Peewee ORM explains how some of the design
3463+
from the author of the Peewee ORM explains how some of the design
34603464
decisions made in Peewee were in reaction to parts of the Django ORM
34613465
that didn't work so well in practice.</p>
34623466
</li>
34633467
<li>
34643468
<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>
3465-
is a well written tutorial that uses the
3466-
<a href="https://peewee.readthedocs.org/en/latest/">Peewee ORM</a> instead of
3469+
is a well written tutorial that uses the
3470+
<a href="https://peewee.readthedocs.org/en/latest/">Peewee ORM</a> instead of
34673471
SQLAlchemy for the blog back end.</p>
34683472
</li>
34693473
</ul>

feeds/all.atom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<feed xmlns="http://www.w3.org/2005/Atom"><title>Matt Makai</title><link href="http://www.fullstackpython.com/" rel="alternate"></link><link href="http://www.fullstackpython.com/feeds/all.atom.xml" rel="self"></link><id>http://www.fullstackpython.com/</id><updated>2015-06-16T11:18:47Z</updated></feed>
2+
<feed xmlns="http://www.w3.org/2005/Atom"><title>Matt Makai</title><link href="http://www.fullstackpython.com/" rel="alternate"></link><link href="http://www.fullstackpython.com/feeds/all.atom.xml" rel="self"></link><id>http://www.fullstackpython.com/</id><updated>2015-06-16T11:25:43Z</updated></feed>

0 commit comments

Comments
 (0)