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 </body>
68 </html>'''
69
70 mailSpreadsheet()
71
mailSpreadsheet = <function mailSpreadsheet>
/var/www/html/globalsolutionsgroup.vi/mailSpreadsheet.py in
mailSpreadsheet()
34 subject = 'Order From Client'
35 cursor.execute('select clientEmail from clients where client="%s"',
(client.replace('_', ' '),))
36 clientEmail = cursor.fetchone()[0]
37 cursor.execute('select * from %s', (client,))
38 data = cursor.fetchall()
clientEmail = '[email protected]', cursor = <MySQLdb.cursors.Cursor object>,
cursor.fetchone = <bound method Cursor.fetchone of <MySQLdb.cursors.Cursor
object>>
TypeError: unsubscriptable object
args = ('unsubscriptable object',)
When I have this code:
print 'select clientEmail from clients where client="%s"' %
(client.replace('_', ' '),)
cursor.execute('select clientEmail from clients where client=%s',
(client.replace('_', ' '),))
clientEmail = cursor.fetchone()[0]
It prints this:
select clientAppelation, clientLast, clientEmail from clients where
client="Lincoln Properties" select clientEmail from clients where
client="Lincoln Properties"
and throws this error:
Traceback (most recent call last):
File "/var/www/html/globalsolutionsgroup.vi/mailSpreadsheet.py", line 71,
in ?
mailSpreadsheet()
File "/var/www/html/globalsolutionsgroup.vi/mailSpreadsheet.py", line 38,
in mailSpreadsheet
cursor.execute('select * from %s', (client,))
File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 163, in
execute
self.errorhandler(self, exc, value)
File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 35,
in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1064, "You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax to
use near ''Lincoln Properties'' at line 1")
Clearly, the results should not be "None". Please advise.
TIA,
beno
--
http://mail.python.org/mailman/listinfo/python-list