- Create a database and table.
- Read json-api and store it into mysql database.
Install requirements.txt
$pip install -r requirements.txt
We need to establish a connection with mysql database. Use your own credentials.
Demo api: https://jsonplaceholder.typicode.com/posts
If you want tot use json file instead of an api, sample json file.
Example:
db_name = "my_book"
table_name = "articles"
Call the function:
create_db(db_name="my_book", table_name="articles")
Run $ python read_json_api.py from command line.
To read data from json file instead from an api, use the following.
with open('book_info.json') as f:
data = json.load(f)