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


Groups > comp.lang.python > #60284

Re: JSON translated into SQL by python

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!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; 'insert': 0.05; 'correct.': 0.07; 'json': 0.07; 'cursor': 0.09; 'exception,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; 'api': 0.11; 'python': 0.11; '"create': 0.16; '"insert': 0.16; '"password",': 0.16; "'%s'": 0.16; 'name",': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'source': 0.25; 'query': 0.26; 'post': 0.26; 'primary': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'wondering': 0.29; 'work.': 0.31; 'code': 0.31; 'too.': 0.31; 'values.': 0.31; 'actual': 0.34; 'amazon': 0.34; 'table': 0.34; 'skip:d 20': 0.34; 'to:addr:python- list': 0.38; 'that,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:it': 0.60; 'new': 0.61; 'cut': 0.74; '(id': 0.84; 'float,': 0.84; 'subject:SQL': 0.84; 'url:y': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: JSON translated into SQL by python
Date Sat, 23 Nov 2013 09:52:02 +0100
Organization None
References <c2e7af6f-0757-4243-9535-eb7bcb59a38f@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084a963.dip0.t-ipconnect.de
User-Agent KNode/4.7.3
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.3075.1385196694.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1385196694 news.xs4all.nl 15863 [2001:888:2000:d::a6]:55527
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:60284

Show key headers only | View raw


Aaron G. wrote:

> I am new to programming python for JSON to SQL and I was wondering why
> this does not work. All the values for entering the DB are correct. The
> EnterpriseValue data is not entering the database.

> #collect data from JSON source at Yahoo
> url = ["db", "http://y.ahoo.it/wlB89"]
> #check all sites
> checkstatus(url[]);
> #retrieve EnterpriseValue data from yahoo to DB
> url = "http://y.ahoo.it/wlB89"
> data = helper.openJSON_URL(url)
> #store data
> curObservation = data["EnterpriseValue"]
> 
> #connect to amazon and post data from Yahoo
> conn = inti_psql_amazon("db name", "db user", "password", "db source")

inti_psql_amazon? Please post your actual code. Cut and paste, don't retype. 
If there's an exception, post that, too. The source code of

do_query_amazon()

might be interesting, too. A commit() on the db cursor might do wonders.

> query = "CREATE TABLE temp2 (ID int NOT NULL AUTO_INCREMENT, 
Enterprise_Value float, PRIMARY KEY(ID));"
> query = "INSERT INTO TABLE temp2 (enterprise) VALUES("+ 
str(curObservation) +");"

As a general remark, don't build your queries like that, rely on the API to 
insert the values. E. g.:

cursor = conn.cursor()
cursor.execute("insert into table temp2 (enterprise) values (?);", 
(curObservation,))

(Some databases use '%s' instead of '?')

> do_query_amazon(conn, query)
> close_psql_amazon(conn)

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


Thread

JSON translated into SQL by python "Aaron G." <another.human.factor@gmail.com> - 2013-11-22 21:54 -0800
  Re: JSON translated into SQL by python Chris Angelico <rosuav@gmail.com> - 2013-11-23 18:35 +1100
  Re: JSON translated into SQL by python Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-11-23 10:06 +0200
  Re: JSON translated into SQL by python Peter Otten <__peter__@web.de> - 2013-11-23 09:52 +0100

csiph-web