Re: [pysqlite] [APSWS] AttributeError: 'tuple' object has no attribute 'lstrip'

Roger Binns <[email protected]> Sun, 04 Jan 2009 23:32:16 -0800
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fred wrote:
> rows=list(cursor.execute(sql))
> for email in rows:

Each row is a tuple.  Your query only returns one column so the row is a
one item tuple.  The tuple is provided as a parameter to sendmail that
expects a string and you get the exception.  If you change the for loop
then the rest of your code will work:

for email in rows:
    email=email[0]  # extract only item from row

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAklht3wACgkQmOOfHg372QRDUACdEO4ZY3RuV3RBNCn4zM3woOdi
mBUAnjqR3h3urRH+PQJAGC4A/2dh/S9T
=2eBP
-----END PGP SIGNATURE-----