Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60284
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: JSON translated into SQL by python |
| Date | 2013-11-23 09:52 +0100 |
| Organization | None |
| References | <c2e7af6f-0757-4243-9535-eb7bcb59a38f@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3075.1385196694.18130.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Find similar | Unroll 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