I'm writing code to convert a json model to SQLite using python. Here is the sample json file:
{
"type":"MetaModel",
"entityName":{
"prefix":"Rail",
"name":"LocationProvider"
},
"attributes":[
{
"name":"abc",
"type":"string",
"maxLength":10,
"mandatory":true
}
],
"constraints":[
{
"name": "PrimaryKey",
"type": "SQLPK",
"fields": [
{
"name":"abc"
}
]
},
{
"name": "ForeignKeyOne",
"type": "SQLFK",
"fields": [
{
"name":"ab"
}
],
"reference":{
"entityName":{
"prefix":"Rail",
"name":"ProvinceState"
},
"fields":[
{
"name":"Code"
}
]
}
}
]
with the below code I'm able to read the foreign key constraints. But I'm struggling to read the "reference" under the SQLFK.
if constraint["name"] == "ForeignKeyOne":
for field in constraint["fields"]:
fk_attribute_list.append(field["name"])
Please help me on how to read the content "reference".
"reference":{
"entityName":{
"prefix":"Rail",
"name":"ProvinceState"
},
"fields":[
{
"name":"Code"
}
]
}
referencein exactly the same way you readname:constraint["reference"]. What, exactly, is giving you trouble?