0

If we have a json format data file which stores all of our database data content, such as table name, row, and column, etc content, how can we use DB-API object to insert/update/delete data from json file into database, such as sqlite, mysql, etc. Or please share if you have better idea to handle it. People said it is good to save database data information into json format, which will be much convenient to work with database in python.

Thanks so much! Please give advise!

user1342336
  • 967
  • 2
  • 16
  • 28
  • Question is a bit broad. Are you having trouble with any particular part of the process? – mechanical_meat Feb 18 '13 at 18:23
  • We may store our database data in a json format file, and then we need to migrate the data from json file into our mysql database where we have already defined the tables. So how can we insert these json data into database tables. Hope it is more clear this time. Thanks. – user1342336 Feb 18 '13 at 21:32
  • Hi,bernie, you seem professional in that work. Actually I have never done something like that before, so please let us know how do you handle this with a simple code example. I really appreciate it. – user1342336 Feb 18 '13 at 21:49

1 Answers1

1

There's no magic way, you'll have to write a Python program to load your JSON data in a database. SQLAlchemy is a good tool to make it easier.

jd.
  • 10,678
  • 3
  • 46
  • 55
  • Can you give some simple working examples, such as loading one table data? I am new to all of these. Do you mean SQLAlchemy tool can also load JSON data into database? Please give more explanation which may also benefit other readers. Thanks very much! – user1342336 Feb 19 '13 at 14:20
  • No, SQLAlchemy doesn't load JSON into a database. It lets you interact with a database. Python's `json` module lets you interact with JSON-serialized data. What goes in-between is for you to write, I don't know a library that does it. Maybe it does exist though, see [PyPI](http://pypi.python.org/pypi). – jd. Feb 19 '13 at 16:01