Στις 1/11/2013 9:12 μμ, ο/η Denis McMahon έγραψε:
On Thu, 31 Oct 2013 11:32:29 +0200, Nick the Gr33k wrote:
The error seen form error log is:
[Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93]
pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)')
(cID, refs, host, city, useros, browser, visits, downloads) )
I suspect the issue is that, as a list type, the pysql interface expects
to map "downloads" to either multiple columns, or one column in multiple
rows, ie it is expecting the list to deliver multiple data items to the
database, but the database is looking for a single data item.
--
I wish not to create an extra MySQL table but just have a column that
can store zero or multiple values within it.
Shall i use a specific column type like ENUM or SET ?
i tried it but this also doenst work.
# 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.append( torrent )
else:
downloads = 'None Yet'
# 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) )
is the baove code correct?
downloads is a list(array of multiple values) or even of zero values.
HOW this 'list' is supposed to get stored into the visitors database?
What colum is able to handle this list?
--
https://mail.python.org/mailman/listinfo/python-list