(Feb-24-2020, 07:45 PM)snippsat Wrote: Use Code Tag,and there is no indentation in code you have posted.
There is mix of two diffent quotation marks in the json sample,that will never work.
"
category”
jk91 Wrote:but how does it match with my problem,i mean here i have very very complex data model like below:-You struggle even with the most basic stuff as usage of OS,files...ect,have you looked into and learned some basic Python?
If this is task you have gotten,ask people who have given it you to help get started.
code (data model used in the problem) with brackets:-
The data model for the database tables is defined as follows.
Data model
[code]
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'})
[code/]
Note:The keys of the dictionary are the table column names, the values are the row values in the database table.
(Feb-25-2020, 04:11 PM)jk91 Wrote:(Feb-24-2020, 07:45 PM)snippsat Wrote: Use Code Tag,and there is no indentation in code you have posted.
There is mix of two diffent quotation marks in the json sample,that will never work.
"
category”
You struggle even with the most basic stuff as usage of OS,files...ect,have you looked into and learned some basic Python?
If this is task you have gotten,ask people who have given it you to help get started.
code (data model used in the problem) with brackets:-
The data model for the database tables is defined as follows.
Data model
[code]
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'})
[code/]
Note:The keys of the dictionary are the table column names, the values are the row values in the database table.
there is a mix of two different quotation marks in the json sample,that will never work.
"
category”
what should it be in a correct way then it might be deliberately so that it hould be a very complex case isn't it?