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


Groups > comp.lang.python > #58333

Re: Retrieving possible list for use in a subsequent INSERT

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'causing': 0.04; 'insert': 0.05; 'string.': 0.05; 'column': 0.07; 'problem?': 0.07; 'table.': 0.07; 'string': 0.09; '??,': 0.09; 'data:': 0.09; 'definition,': 0.09; 'inserted': 0.09; 'insertion': 0.09; 'null,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'comma': 0.16; 'defined.': 0.16; 'hits': 0.16; 'list)': 0.16; 'message- id:@4ax.com': 0.16; 'nick': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'repr()': 0.16; 'requires:': 0.16; 'separated': 0.16; 'skip:> 20': 0.16; 'subject:possible': 0.16; 'index': 0.16; 'have:': 0.19; 'split': 0.19; '(the': 0.22; '>>>': 0.22; 'error': 0.23; 'url:home': 0.24; 'references': 0.26; 'this:': 0.26; 'second': 0.26; 'primary': 0.26; 'values': 0.27; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'host': 0.29; "we'd": 0.29; 'list:': 0.30; 'subject:list': 0.30; 'relational': 0.31; 'table,': 0.31; 'fri,': 0.33; 'table': 0.34; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'convert': 0.35; 'add': 0.35; '+0200,': 0.36; 'data,': 0.36; 'like,': 0.36; 'entry': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.36; 'should': 0.36; 'skip:4 10': 0.37; 'list': 0.37; 'list.': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'browser': 0.61; 'back': 0.62; 'field': 0.63; 'skip:n 10': 0.64; 'email addr:yahoo.com': 0.64; 'city': 0.66; 'default': 0.69; 'foreign': 0.74; 'bitmap': 0.84; 'visits': 0.84; 'received:108': 0.93; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Retrieving possible list for use in a subsequent INSERT
Date Sat, 02 Nov 2013 12:58:07 -0400
Organization IISS Elusive Unicorn
References <l4t7jt$52m$1@dont-email.me> <l4t83c$7cn$1@dont-email.me> <e1b4046c-3180-4ad8-a90a-6e87dd4df6ba@googlegroups.com> <l4ulbn$po8$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-68-176-125.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1954.1383411486.18130.python-list@python.org> (permalink)
Lines 70
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1383411486 news.xs4all.nl 15919 [2001:888:2000:d::a6]:49713
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:58333

Show key headers only | View raw


On Fri, 01 Nov 2013 00:24:57 +0200, Nick the Gr33k <nikos.gr33k@gmail.com>
declaimed the following:

>???? 31/10/2013 9:22 ??, ?/? rurpy@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 )
>
>create table visitors
>(
>   counterID integer(5) not null,
>   host varchar(50) not null,
>   refs varchar(25) not null,
>   city varchar(20) not null,
>   userOS varchar(10) not null,
>   browser varchar(10) not null,
>   hits integer(5) not null default 1,
>   visits datetime not null,
>   downloads set('????? ?????'),
>   foreign key (counterID) references counters(ID),
>   unique index (visits)
>  )ENGINE = MYISAM;
>
>Decided to declare downlods as  SET column type.
>and maintain this:
>
>		downloads = []
>		if data:
>			for torrent in data:
>				downloads.append( torrent )
>
>
>but error still is:
>
>[Thu Oct 31 22:24:41 2013] [error] [client 46.198.103.93] 
>pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)')

	MySQL SET data type requires: 1) that you PREDEFINE ALL POSSIBLE values
in the table definition, and 2) that the data inserted into that field is a
comma separated STRING. Not a list, not a repr() of a list. What actually
gets saved in the database is a bitmap of the position of the values
defined.

	For an ad hoc list of data, the proper method -- for any relational
database requires normalization. That is, you split the repeating group
(the list) out into a second table, with one entry per row, and a foreign
key linking back to the original table. But, since you don't have a primary
key on your data, we'd have to add that first...

-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web