Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58156 > unrolled thread

Retrieving possible list for use in a subsequent INSERT

Started byNick the Gr33k <nikos.gr33k@gmail.com>
First post2013-10-31 11:24 +0200
Last post2013-11-02 16:41 +0000
Articles 4 on this page of 24 — 8 participants

Back to article view | Back to comp.lang.python


Contents

  Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-10-31 11:24 +0200
    Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-10-31 11:32 +0200
      Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-10-31 13:19 +0200
        Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-10-31 18:49 +0200
          Re: Retrieving possible list for use in a subsequent INSERT Christian Gollwitzer <auriocus@gmx.de> - 2013-10-31 19:05 +0100
      Re: Retrieving possible list for use in a subsequent INSERT rurpy@yahoo.com - 2013-10-31 12:22 -0700
        Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-10-31 23:54 +0200
        Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-01 00:24 +0200
          Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-01 17:04 +0200
            Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-01 17:52 +0200
            Re: Retrieving possible list for use in a subsequent INSERT rurpy@yahoo.com - 2013-11-01 19:00 -0700
              Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-02 10:49 +0200
                Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-02 12:57 +0200
                Re: Retrieving possible list for use in a subsequent INSERT Lele Gaifax <lele@metapensiero.it> - 2013-11-02 12:32 +0100
          Re: Retrieving possible list for use in a subsequent INSERT Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-02 12:58 -0400
        Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-01 17:25 +0200
          Re: Retrieving possible list for use in a subsequent INSERT Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-01 11:56 -0400
            Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-01 18:00 +0200
            Re: Retrieving possible list for use in a subsequent INSERT "Paul Simon" <psimon@sonic.net> - 2013-11-01 10:07 -0700
              Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-01 19:35 +0200
                Re: Retrieving possible list for use in a subsequent INSERT "Paul Simon" <psimon@sonic.net> - 2013-11-01 12:19 -0700
      Re: Retrieving possible list for use in a subsequent INSERT Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-01 19:12 +0000
        Re: Retrieving possible list for use in a subsequent INSERT Nick the Gr33k <nikos.gr33k@gmail.com> - 2013-11-02 02:06 +0200
          Re: Retrieving possible list for use in a subsequent INSERT Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-02 16:41 +0000

Page 2 of 2 — ← Prev page 1 [2]


#58287

From"Paul Simon" <psimon@sonic.net>
Date2013-11-01 12:19 -0700
Message-ID<52740034$0$52732$742ec2ed@news.sonic.net>
In reply to#58283
"Nick the Gr33k" <nikos.gr33k@gmail.com> wrote in message 
news:l50oo5$k05$1@dont-email.me...
> ???? 1/11/2013 7:07 ??, ?/? Paul Simon ??????:
>
>> If you have a list of values of the same type, but different values,
>> you need a new table with a foreign key to the table it relates to.
>> This is a relational database question.  You can read more here:
>>
>> http://en.wikipedia.org/wiki/Database_normalization#Normal_forms
>
> I already answered to that in my previous post, this answer was Joel's 
> there was no need to retype it since i i saw it and responded to it.

Perhaps you misunderstood my response to Joel's comment.  You don't <need> a 
many to many table as he said above in your quote.  That's required for a 
normal form but isn't necessary.  Denormalize the many to many form, have 
duplicated data in your only table if that works for you.  Storage is cheap 
and its easier to create sql stsatements, too.

Paul Simon 

[toc] | [prev] | [next] | [standalone]


#58286

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-11-01 19:12 +0000
Message-ID<l50uee$msm$5@dont-email.me>
In reply to#58158
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.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#58299

FromNick the Gr33k <nikos.gr33k@gmail.com>
Date2013-11-02 02:06 +0200
Message-ID<l51fn3$7tq$2@dont-email.me>
In reply to#58286
Στις 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?

[toc] | [prev] | [next] | [standalone]


#58330

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-11-02 16:41 +0000
Message-ID<l539vp$7bf$1@dont-email.me>
In reply to#58299
On Sat, 02 Nov 2013 02:06:59 +0200, Nick the Gr33k wrote:

> HOW this 'list' is supposed to get stored into the visitors database?

> What colum is able to handle this list?

A python list is a python datatype. mysql has no equivalent data type to 
a python list. You need to convert your python list into a data element 
or elements that mysql understands.

The way I would do it would be to use a table for downloads list where 
each download was linked to the visitor who had downloaded it.

I'm sure all the future users of your torrent search website will be 
pleased to know just how much unnecessary data you are attempting to 
capture about their torrenting activities. When the CIA and the FBI 
persuade the greek government to let them impound your servers, all your 
users worldwide will have their torrenting history laid out in full, 
which I'm sure will please anyone who wishes to litigate against them.

Note also that Greece is part of the EU and that makes your website 
subject to EU data protection requirements. You have to tell your users 
what data you are collecting and storing, and why you are collecting and 
storing it, and you must destroy the data once it is no longer needed.

As an observation, if you are simply providing a torrent search engine, 
you do not need to log or record anything at all.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web