Re: Another MySQL Problem

2010-06-26 Thread Victor Subervi
On Fri, Jun 25, 2010 at 2:15 AM, Dennis Lee Bieber wrote: > On Thu, 24 Jun 2010 09:59:41 -0430, Victor Subervi > declaimed the following in > gmane.comp.python.general: > >I could have sworn the concept had been brought up some 8 months > ago... Probably couched in relational database ter

Re: Another MySQL Problem

2010-06-24 Thread Victor Subervi
On Thu, Jun 24, 2010 at 9:34 AM, Stephen Hansen wrote: > On Thu, Jun 24, 2010 at 4:47 AM, Victor Subervi > wrote: > >> On Thu, Jun 24, 2010 at 1:56 AM, John Nagle wrote: >> > Yes. Please post your CREATE statements, so we can see your >>> database schema. If you really have one table per c

Re: Another MySQL Problem

2010-06-24 Thread Stephen Hansen
On Thu, Jun 24, 2010 at 4:47 AM, Victor Subervi wrote: > On Thu, Jun 24, 2010 at 1:56 AM, John Nagle wrote: > Yes. Please post your CREATE statements, so we can see your >> database schema. If you really have one table per client, you're >> doing it wrong. >> > > cursor.execute('create tabl

Re: Another MySQL Problem

2010-06-24 Thread Victor Subervi
On Thu, Jun 24, 2010 at 1:56 AM, John Nagle wrote: > On 6/23/2010 10:59 PM, Dennis Lee Bieber wrote: > >> On Wed, 23 Jun 2010 11:58:24 -0430, Victor Subervi >> declaimed the following in >> gmane.comp.python.general: >> >> >> When I have this code: >>> >> > > >>And yes -- it IS an

Re: Another MySQL Problem

2010-06-23 Thread John Nagle
On 6/23/2010 10:59 PM, Dennis Lee Bieber wrote: On Wed, 23 Jun 2010 11:58:24 -0430, Victor Subervi declaimed the following in gmane.comp.python.general: When I have this code: And yes -- it IS an error... You are AGAIN trying to use parameters for SCHEMA entities, not data.

Re: Another MySQL Problem

2010-06-23 Thread Stephen Hansen
On Jun 23, 2010, at 11:20 AM, Victor Subervi wrote: On Wed, Jun 23, 2010 at 12:51 PM, Stephen Hansen wrote: > The problem is not this line but: > > > File "/var/www/html/globalsolutionsgroup.vi/mailSpreadsheet.py", line > 38, in mailSpreadsheet > cursor.execute('select * from %s', (client

Re: Another MySQL Problem

2010-06-23 Thread Victor Subervi
On Wed, Jun 23, 2010 at 12:51 PM, Stephen Hansen wrote: > The problem is not this line but: > > > File "/var/www/html/globalsolutionsgroup.vi/mailSpreadsheet.py", line > 38, in mailSpreadsheet > cursor.execute('select * from %s', (client,)) > > > This one. > Yes, can't use the comma, must

Re: Another MySQL Problem

2010-06-23 Thread Stephen Hansen
On Jun 23, 2010, at 9:28 AM, Victor Subervi wrote: Ok, let's start all over again. When I have this code: cursor.execute('select clientEmail from clients where client="%s"', (client.replace('_', ' '),)) clientEmail = cursor.fetchone()[0] Already addressed this. Do not quote inside the SQL.

Re: Another MySQL Problem

2010-06-23 Thread Stephen Hansen
On Jun 23, 2010, at 9:12 AM, Paul Rubin wrote: Stephen Hansen writes: On 6/23/10 6:45 AM, Victor Subervi wrote: cursor.execute('select clientEmail from clients where client=%s', ... Do, 'client.replace("_", " ")' instead. Er, look what happened to Little Bobby Tables (a quick web search on

Re: Another MySQL Problem

2010-06-23 Thread Victor Subervi
Ok, let's start all over again. When I have this code: cursor.execute('select clientEmail from clients where client="%s"', (client.replace('_', ' '),)) clientEmail = cursor.fetchone()[0] I get this error: /var/www/html/globalsolutionsgroup.vi/mailSpreadsheet.py 67 68 ''' 69 70

Re: Another MySQL Problem

2010-06-23 Thread Tim Chase
On 06/23/2010 08:45 AM, Victor Subervi wrote: Hi; I have this line: cursor.execute('select clientEmail from clients where client=%s', (string.replace(client, '_', ' '))) clientEmail = cursor.fetchone()[0] cursor.execute('select * from %s' % (client)) client = "Lincoln_Properties" With

Re: Another MySQL Problem

2010-06-23 Thread Tapi
On Wed, 23 Jun 2010 10:46:37 -0430, Victor Subervi wrote: > On Wed, Jun 23, 2010 at 10:25 AM, Stephen Hansen > wrote: > >> On 6/23/10 6:45 AM, Victor Subervi wrote: >> > Hi; >> > I have this line: >> > >> > cursor.execute('select clientEmail from clients where client=%s', >> > (string.replace(c

Re: Another MySQL Problem

2010-06-23 Thread Paul Rubin
Stephen Hansen writes: >On 6/23/10 6:45 AM, Victor Subervi wrote: >> cursor.execute('select clientEmail from clients where client=%s', ... > Do, 'client.replace("_", " ")' instead. Er, look what happened to Little Bobby Tables (a quick web search on his name should find his story) because someo

Re: Another MySQL Problem

2010-06-23 Thread Simon Malinge
On Wed, 23 Jun 2010 10:46:37 -0430, Victor Subervi wrote: > On Wed, Jun 23, 2010 at 10:25 AM, Stephen Hansen > wrote: > >> On 6/23/10 6:45 AM, Victor Subervi wrote: >> > Hi; >> > I have this line: >> > >> > cursor.execute('select clientEmail from clients where client=%s', >> > (string.replace(c

Re: Another MySQL Problem

2010-06-23 Thread Stephen Hansen
On 6/23/10 8:16 AM, Victor Subervi wrote: > On Wed, Jun 23, 2010 at 10:25 AM, Stephen Hansen > mailto:pyt...@ixokai.io>> wrote: > > On 6/23/10 6:45 AM, Victor Subervi wrote: > > Hi; > > I have this line: > > > > cursor.execute('select clientEmail from clients where client=%s'

Re: Another MySQL Problem

2010-06-23 Thread Victor Subervi
On Wed, Jun 23, 2010 at 10:25 AM, Stephen Hansen wrote: > On 6/23/10 6:45 AM, Victor Subervi wrote: > > Hi; > > I have this line: > > > > cursor.execute('select clientEmail from clients where client=%s', > > (string.replace(client, '_', ' '))) > > clientEmail = cursor.fetchone()[0] > > curso

Re: Another MySQL Problem

2010-06-23 Thread Stephen Hansen
On 6/23/10 6:45 AM, Victor Subervi wrote: > Hi; > I have this line: > > cursor.execute('select clientEmail from clients where client=%s', > (string.replace(client, '_', ' '))) > clientEmail = cursor.fetchone()[0] > cursor.execute('select * from %s' % (client)) > > client = "Lincoln_Properti

Another MySQL Problem

2010-06-23 Thread Victor Subervi
Hi; I have this line: cursor.execute('select clientEmail from clients where client=%s', (string.replace(client, '_', ' '))) clientEmail = cursor.fetchone()[0] cursor.execute('select * from %s' % (client)) client = "Lincoln_Properties" With the replacement, the interpreter complains that myd

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"

Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
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");' % (personalDataTable, string.join(cols[1:], ', '), string.join(va

Re: Another MySQL Problem

2009-12-18 Thread John Nagle
MRAB wrote: Victor Subervi wrote: Hi; mysql> truncate tem126072414516; Query OK, 0 rows affected (0.00 sec) Then I run a script: if whatDo == 'insert': try: sql = 'insert into %s (ProdID, Quantity) values ("%s", "%s");' % (tmpTable, prodid, quantity) print sql cursor

Re: Another MySQL Problem

2009-12-13 Thread Victor Subervi
On Sun, Dec 13, 2009 at 1:37 PM, MRAB wrote: > 2. Did you commit the changes? > Ah, yes, caught me napping! db.commit() has bit me in the a$$ again. Thanks, V -- http://mail.python.org/mailman/listinfo/python-list

Re: Another MySQL Problem

2009-12-13 Thread MRAB
Victor Subervi wrote: Hi; mysql> truncate tem126072414516; Query OK, 0 rows affected (0.00 sec) Then I run a script: if whatDo == 'insert': try: sql = 'insert into %s (ProdID, Quantity) values ("%s", "%s");' % (tmpTable, prodid, quantity) print sql cursor.execute(sql)

Another MySQL Problem

2009-12-13 Thread Victor Subervi
Hi; mysql> truncate tem126072414516; Query OK, 0 rows affected (0.00 sec) Then I run a script: if whatDo == 'insert': try: sql = 'insert into %s (ProdID, Quantity) values ("%s", "%s");' % (tmpTable, prodid, quantity) print sql cursor.execute(sql) that runs this (printed