Feb-24-2020, 06:22 PM
(Feb-24-2020, 01:45 PM)snippsat Wrote: Ohhhhh you have not even doneFile --> New Notebook
still in starting notebook intro.
Shall not selectdata.json
have to upload it as i show with image.
You shall do nothing with the data.json after download other than maybe move to a folder of choice.
Last try here a video from start to finish.
ok,thanks.
but how does it match with my problem,i mean here i have very very complex data model like below:-
Introduction
Someone wants to manage their website. One of
the most important pages on their website is the “Menu” page.The menu gets updated every
night at the restaurant and Joe’s grill wants the updated menu published to their website every
morning. customer will upload their menu in a JSON formatted file (Let’s call it menu.json) to our
ftp server every night.
Requirement is to develop a program to take this menu.json file and store the data
in a relational database. The data model for the database tables is defined as follows.
Data model
items: id(pkey), name
categories: id(pkey), name
category_items: id(pkey), category_id (fkey categories), item_id(fkey items)
menu.json
{
"category”:[{
“name”: “Appetizer”,
},
{
“name”: “Entree”
}
]
],
"item”:[
{
"name":"French Fries",
"category":"Appetizer"
},
{
"name":"Onion Rings",
"category":"Appetizer"
},
{
"name":"Sandwich",
"category":"Entree"
},
{
"name":"Tacos",
"category":"Entree"
},
{
"name":"Ice Cream Sundae",
"category":"Dessert"
}
],
"restaurant":"Joe's Grill"
}
}
Existing classes:
class category:
def __init__(self, name):
self.name = name
class item:
def __init__(self, name, category_name):
self.name = name
self.category_name = category_name
Helper Functions that Already exist
// json.get_categories(file_name) -> returns array of active category objects (category.name)
// json.get_items(file_name) --> returns array of item object (item.name, item.category_name)
// db.write(table_name, <a data dict or an array of data dicts>) //db.write('categories', {'name':
'c1'})
Note:The keys of the dictionary are the table column names, the values are the row values in
the database table