[Chicago] Chicago Digest, Vol 58, Issue 1

Walter Askew waltaskew at gmail.com
Tue Jun 1 20:53:50 CEST 2010


MySQLdb is a very no-frills package.  No-frills as in it doesn't support anything fancy like 'laziness' or 'real prepared statements'.  
I'm not joking about the no prepared statements thing.  You can write stuff like this:
c=db.cursor()
max_price=5
c.execute("""SELECT spam, eggs, sausage FROM breakfast
          WHERE price < %s""", (max_price,))
And it's pretty much what it looks like -- string interpolation.
For more featureful libraries, there's oursql (I've never used it myself) and the ever popular SQLAlchemy

I'm not sure how big of a project this is, but I've only used MySQLdb for writing one-off scripts (for which it's great.)  Especially for a larger project, using an ORM like SQLAlchemy can definitely be more pleasant than writing SQL by hand.  Plus, seriously, real prepared statements and laziness.

On Jun 1, 2010, at 5:00 AM, chicago-request at python.org wrote:

> Send Chicago mailing list submissions to
> 	chicago at python.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://mail.python.org/mailman/listinfo/chicago
> or, via email, send a message with subject or body 'help' to
> 	chicago-request at python.org
> 
> You can reach the person managing the list at
> 	chicago-owner at python.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Chicago digest..."
> Today's Topics:
> 
>   1. MySQL from unprivileged account (Jonathan Hayward)
> 
> From: Jonathan Hayward <christos.jonathan.hayward at gmail.com>
> Date: May 31, 2010 10:55:48 AM CDT
> To: The Chicago Python Users Group <chicago at python.org>
> Subject: [Chicago] MySQL from unprivileged account
> Reply-To: The Chicago Python Users Group <chicago at python.org>
> 
> 
> I would like to migrate a project from a custom database to using MySQL. The target system is a Linux system where I have unprivileged shell access and setuptools is installed. After playing around with easy_install and setting my PYTHONPATH, I have MySQLdb working, or at least importing.
> 
> Before I go further, I wanted to ask opinions on preferred ways of dealing with MySQL from Python. Is there any one package which is strongly preferred, and in particular is MySQLdb a choice to warn about, or a sane choice with sensible adherents?
> 
> -- 
> → Jonathan Hayward, christos.jonathan.hayward at gmail.com
> → An Orthodox Christian author: theology, literature, et cetera.
> → My award-winning collection is available for free reading online:
> ☩ I invite you to visit my main site at http://JonathansCorner.com/
> 
> 
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20100601/4e424618/attachment.html>


More information about the Chicago mailing list