Στις 31/10/2013 9:22 μμ, ο/η ru...@yahoo.com έγραψε:
You set the value of 'downloads' to a list:
downloads = []
if data:
for torrent in data:
downloads.append( torrent )
and when you use 'downloads', use have:
INSERT INTO visitors (..., downloads) VALUES (..., %s), (..., downloads)
If the 'downloads' column in table 'visitors' is a
normal scalar value (text string or such) then perhaps
you can't insert a value that is a list into it? And
that may be causing your problem?
If that is in fact the problem (I am only guessing), you
could convert 'downloads' to a single string for insertion
into your database with something like,
downloads = ', '.join( downloads )
Hello rurpy! I haven't forget ypu still have to answer you i the other
thread for the big explanation you provided, i just didnt had the time yet!
Yes indeed by MySQL's time definition 'downloads' columns is set as:
'varchar(50) not null'
So we have 2 options as you said:
1. Alter the type of 'downloads' colums to soemthign that can hold a list
2. Alter the code to make list beceome an alltogether joined string.
# find out if visitor had downloaded torrents in the past
cur.execute('''SELECT torrent FROM files WHERE host = %s''',
host )
data = cur.fetchall()
downloads = []
if data:
for torrent in data:
downloads = ', '.join( downloads )
else:
downloads = None
# add this visitor entry into database (host && downloads are
unique)
cur.execute('''INSERT INTO visitors (counterID, refs, host, city,
useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s,
%s)''', (cID, refs, host, city, useros, browser, visits, downloads) )
I can be seen here: http://superhost.gr/?show=log&page=index.html
But this unfortunate;y do not produce proper results
--
https://mail.python.org/mailman/listinfo/python-list