???????? ?????? <nikos.gr...@gmail.com> wrote: > >[code] > if not re.search( '=', name ) and not re.search( '=', month ) > and not re.search( '=', year ): > cur.execute( '''SELECT * FROM works WHERE clientsID = > (SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and > YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (name, month, year) ) > elif not re.search( '=', month ) and not re.search( '=', year ): > cur.execute( '''SELECT * FROM works WHERE > MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', > (month, year) ) > elif not re.search( '=', year ): > cur.execute( '''SELECT * FROM works WHERE > YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year )
There is so much you didn't tell us here, including which database you are using. With most Python database adapters, the second parameter of the "execute" method must be a tuple. "year" is not a tuple. My guess is that this will work fine: cur.execute( "SELECT * FROM works WHERE YEAR(lastvisit)=%s ORDER BY lastvisit", (year,) ) It seems silly to fire up a regular expression compiler to look for a single character. if name.find('=') < 0 and month.find('=') < 0 and year.find('=') < 0: -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list