JSON translated into SQL by python
jpiitula at ling.helsinki.fi
Sat Nov 23 09:06:55 CET 2013
Aaron G. writes:
> 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
> #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")
> 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) +");"
> do_query_amazon(conn, query)
Possibly you should let the database know about the first query. Now
it's just a very short-lived string in the Python program.
Is there no exception?
My inclination would be to go to the Python interpreter and try very
simple interactions with the database. Create a table with only one
column. Insert one value. See if the value is there. Hello, world.
More information about the Python-list