Στις 2/11/2013 3:03 μμ, ο/η Andreas Perstinger έγραψε:
On 02.11.2013 12:58, Nick the Gr33k wrote:
Trying to add the current filename into the existent 'downloads' column
Somehow i don't think i just use the plus sign into an existing column.
We don't try to add numbers here but add an extra string to an already
existing array of strings(list).
[SNIP]
# update specific visitor's download record
cur.execute('''UPDATE visitors SET downloads = downloads + %s WHERE host
= %s''', (filename, host) )
======================================================
Well, when do you understand that your MySQL problems have nothing to do
with Python?
Everything inside the triple quotes is MySQL specific, so it's a MySQL
problem whether you can use + to "add an extra string to an already
existing array of strings(list)".
This list is not a MySQL support forum.
Bye, Andreas
[code]
# 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) )
[/code]
This works bit questios thas arises is what is its difference compare to:
downloads.append( torrent )
Are both these statements create a list?
But in the latter we get the famous:
pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)')
while in the join() we arent getting this.
I just want a mysql column type that can be eligible to store an array
of elements, a list that is, no need for having a seperate extra table
for that if we can have a column that can store a list of values.
--
What is now proved was at first only imagined! & WebHost
<http://superhost.gr>
--
https://mail.python.org/mailman/listinfo/python-list