def getall(sdate, list):
...
e = Con.cursor()
for x in list:
e.execute("""select plz from bericht where sdatum=%s and paket=%s order by plz""", (sdate, x))
sam = e.fetchone()
erg.append(sam)
return erg
And the result is:
Traceback (most recent call last):
File "einoalsp.py", line 65, in ?
ergebnis('2002-04-02')
File "einoalsp.py", line 61, in ergebnis
getall(sdate, rest)
File "einoalsp.py", line 49, in getall
e.execute("""select plz from bericht where sdatum=%s and paket=%s order by plz""", (sdate, x))
File "C:\Python21\MySQLdb\cursors.py", line 66, in execute
r = self._query(query % self.__conn.literal(args))
File "C:\Python21\MySQLdb\cursors.py", line 168, in _query
rowcount = self._BaseCursor__do_query(q)
File "C:\Python21\MySQLdb\cursors.py", line 112, in __do_query
db.query(q)
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax near ') order by plz' at line 1")
(sdate ) without loop and (x) without (sdate) is working, so I think the loop is the problem.
Can anyone help me solving this?
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm trying this:
def getall(sdate, list):
...
e = Con.cursor()
for x in list:
e.execute("""select plz from bericht where sdatum=%s and paket=%s order by plz""", (sdate, x))
sam = e.fetchone()
erg.append(sam)
return erg
And the result is:
Traceback (most recent call last):
File "einoalsp.py", line 65, in ?
ergebnis('2002-04-02')
File "einoalsp.py", line 61, in ergebnis
getall(sdate, rest)
File "einoalsp.py", line 49, in getall
e.execute("""select plz from bericht where sdatum=%s and paket=%s order by plz""", (sdate, x))
File "C:\Python21\MySQLdb\cursors.py", line 66, in execute
r = self._query(query % self.__conn.literal(args))
File "C:\Python21\MySQLdb\cursors.py", line 168, in _query
rowcount = self._BaseCursor__do_query(q)
File "C:\Python21\MySQLdb\cursors.py", line 112, in __do_query
db.query(q)
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax near ') order by plz' at line 1")
(sdate ) without loop and (x) without (sdate) is working, so I think the loop is the problem.
Can anyone help me solving this?
Thomas
Are you sure x isn't a tuple?