Re: Yet Another MySQL Problem

2010-05-28 Thread Malcolm Greene
Tim, > The underscore is a valid variable-name, idiomatically used for "I don't care > about this", often seen in places like tuple assignment: The underscore is also used as an alias for gettext.gettext or gettext.ugettext so you may want to use another variable-name. Malcolm -- http://mail.p

Re: Yet Another MySQL Problem

2010-05-28 Thread Victor Subervi
On Thu, May 27, 2010 at 5:47 PM, Tim Chase wrote: > On 05/27/2010 03:32 PM, Victor Subervi wrote: > > On Thu, May 27, 2010 at 1:15 PM, Tim Chase wrote: >> >>> That should be: ', '.join(['%s'] * len(values))) >>> >>> Or as I've done in the past: >>> >>> ', '.join('%s' for _

Re: Yet Another MySQL Problem

2010-05-27 Thread Tim Chase
On 05/27/2010 03:32 PM, Victor Subervi wrote: On Thu, May 27, 2010 at 1:15 PM, Tim Chase wrote: That should be: ', '.join(['%s'] * len(values))) Or as I've done in the past: ', '.join('%s' for _ in values) Huh? Can you describe that underscore to me? Fascinating! The underscor

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 1:15 PM, Tim Chase wrote: > On 05/27/2010 11:56 AM, MRAB wrote: > >> Kushal Kumaran wrote: >> >>>', '.join('%s' * len(values))) >>> >> >> That should be: >> >> ', '.join(['%s'] * len(values))) >> > > Or as I've done in the past: > > ', '.join('%s' for _ in

Re: Yet Another MySQL Problem

2010-05-27 Thread Tim Chase
On 05/27/2010 11:56 AM, MRAB wrote: Kushal Kumaran wrote: ', '.join('%s' * len(values))) That should be: ', '.join(['%s'] * len(values))) Or as I've done in the past: ', '.join('%s' for _ in values) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 12:56 PM, MRAB wrote: > Kushal Kumaran wrote: > [snip] > > Since I'm in a good mood today, here's a little present: >> >> def insert(cursor, table, columns, values): >>"""Insert a row into a table. columns must be a list of column >>names. values must be a list

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 17:56 +0100, MRAB wrote: > Kushal Kumaran wrote: > [snip] > > Since I'm in a good mood today, here's a little present: > > > > def insert(cursor, table, columns, values): > > """Insert a row into a table. columns must be a list of column > > names. values must be a

Re: Yet Another MySQL Problem

2010-05-27 Thread MRAB
Kushal Kumaran wrote: [snip] Since I'm in a good mood today, here's a little present: def insert(cursor, table, columns, values): """Insert a row into a table. columns must be a list of column names. values must be a list of values for the new row. The columns and values must corr

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 12:11 PM, Kushal Kumaran wrote: > Since I'm in a good mood today, here's a little present: > > def insert(cursor, table, columns, values): >"""Insert a row into a table. columns must be a list of column >names. values must be a list of values for the new row. The

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 20:47 +0530, Kushal Kumaran wrote: > On Thu, 2010-05-27 at 10:30 -0400, Victor Subervi wrote: > > On Thu, May 27, 2010 at 10:17 AM, Kushal Kumaran > > wrote: > > > > On Thu, 2010-05-27 at 08:34 -0400, Victor Subervi wrote: > > > Hi; > > > I ha

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 10:30 -0400, Victor Subervi wrote: > On Thu, May 27, 2010 at 10:17 AM, Kushal Kumaran > wrote: > > On Thu, 2010-05-27 at 08:34 -0400, Victor Subervi wrote: > > Hi; > > I have this code: > > > > sql = "insert into %s (%s) va

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 10:17 AM, Kushal Kumaran wrote: > On Thu, 2010-05-27 at 08:34 -0400, Victor Subervi wrote: > > Hi; > > I have this code: > > > > sql = "insert into %s (%s) values ('%%s');" % (personalDataTable, > > string.join(cols[1:], ', ')) > > #cursor.execute(sql, string.join(v

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 09:34 -0400, Victor Subervi wrote: > On Thu, May 27, 2010 at 8:34 AM, Victor Subervi > wrote: > Hi; > I have this code: > > sql = "insert into %s (%s) values ('%%s');" % > (personalDataTable, string.join(cols[1:], ', ')) >

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 08:34 -0400, Victor Subervi wrote: > Hi; > I have this code: > > sql = "insert into %s (%s) values ('%%s');" % (personalDataTable, > string.join(cols[1:], ', ')) > #cursor.execute(sql, string.join(vals[1:], "', '")) > cursor.execute('insert into %s (%s) values ("%

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 8:34 AM, Victor Subervi wrote: > Hi; > I have this code: > > sql = "insert into %s (%s) values ('%%s');" % (personalDataTable, > string.join(cols[1:], ', ')) > #cursor.execute(sql, string.join(vals[1:], "', '")) > cursor.execute('insert into %s (%s) values ("%s"