-1

I need to import JSON data from an API to MySQL database using python. I can get the json data in python script but no idea how to insert this data to a mysql database.

muteeb
  • 1
  • 1
  • What have you tried? How do you want it saved? – Isdj Jan 15 '20 at 08:07
  • after getting the api data through python, i need to insert this data into a mysql database. the api data contains long list of objects, lists. I converted JSON to python dictionary & then tried to access the key values using indexes which is working but how do i export dictionary data to appropriate table & columns. – muteeb Jan 15 '20 at 11:59

2 Answers2

0

finally, did it. Saved the JSON file locally first, then parsed it using key values in a for loop & lastly ran a query to insert into MySQL table.

muteeb
  • 1
  • 1
-1

Serializing JSON to string and insert string to DB, and make it Deserializing when you want to use it. I use this method but I don't know if it is optimum

Working With JSON Data in Python

Leon
  • 24
  • 3
  • i saved the json file. Now i need to export that data to mysql in python. I already know how to run mysql in python but how do i create insert queries for json file. – muteeb Jan 15 '20 at 12:02
  • Look at this: [Storing Data in MySQL as JSON ](https://stackoverflow.com/questions/3564024/storing-data-in-mysql-as-json). – Leon Jan 15 '20 at 14:09