Am 28.08.2013 10:48, schrieb Ferrous Cranus:
>> I quote from a Python 3 Guide
>> [http://python.about.com/od/python30/ss/30_strings_3.htm]:
>>
>> The two data types, str and bytes, are mutually exclusive. One
>> cannot
>> legally combine them into one call. With the distinction between
>> text
>> and data, therefore, comes the need to convert between them.
>>
>>
>
> So, in this line:
>
> cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
>
> the variable 'page' needs conversion to what?
>
> all that is stores is the location of a file
>
> path = '/home/nikos/public_html/'
>
> page = form.getvalue('page')
>
> if not page and os.path.exists( file ):
> # it is an html template
> page = file.replace( path, '' )
>
> So chnage it to what?
> --
> What is now proved was at first only imagined!
The error occurs in file
"/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py",
line 108, in execute
query = query % escaped_args
You can check the actual values and data types using:
print repr(query)
print type(query)
print repr(escaped_args)
print type(escaped_args)
Always useful is a proper exception handling using try:/except:
hOW YOU MEAN PLEASE I TRY TO IMPLMENT WHAT YOU PROPOSE BUT I CANT.
try:
#find the needed counter for the page URL
if os.path.exists( path + page ) or os.path.exists( cgi_path + page
):
cur.execute('''SELECT ID FROM counters WHERE url =
%s''', page )
data = cur.fetchone() #URL is unique, so
should only be one
print repr('''SELECT ID FROM counters WHERE url = %s''')
print type('''SELECT ID FROM counters WHERE url = %s''')
print repr(escaped_args)
print type(escaped_args)
I MEAN IF FAILS BEFORE IT TRIES TO GO INTO MY PRINT STAEMNT.
HOW AM I GONNA CPATURE THE QUERY?
http://i.stack.imgur.com/jiFfM.jpg
http://wiki.python.org/moin/HandlingExceptions
--
http://mail.python.org/mailman/listinfo/python-list