Re[2]: [workshop] generic sql storage in python

Michal Wallace workshop@cornerhost.com
Thu, 9 May 2002 03:42:53 -0400 (Eastern Daylight Time)


On Thu, 09 May 2002 16:09:27 +1000, Andy Todd wrote:

>          sql += " WHERE ID = %d" % row["ID"]
...
> Without the "WHERE" clause it always trys to update every row in the
> table.

D'oh! :) Thanks! I'd been doing all my testing with MockStorage,
and just never noticed. 

 
> This perplexed me for quite a while (which isn't that hard) until I 
> realised that this column HAD to be the primary key *and* had to be an 
> AUTO_INCREMENT column, e.g.;

Yep. 


>  >>> db = MySQLdb.connect( db='test' )
>  >>> storage = MySQLStorage( db )
>  >>> storage.store('test_storage', COL1='COL1 Value', COL2='Col2 Value')
> 
> Don't - as I did - try and pass in a dictionary of column name:value 
> pairs because that just confuses everyone.

If you want to do that, you can use the ** syntax:

   >>> storage.store('test_storage', **dictionaryOfNameValuePairs)

I figured that way you had the choice. :)

Sincerely,

Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: michal@sabren.com
hosting: http://www.cornerhost.com/
my site: http://www.sabren.net/
--------------------------------------