| 167 | cur.execute('truncate table item_map_text') |
| 168 | |
| 169 | def create_schema(client_name, dbSettings, scheme_file_path, clean=False): |
| 170 | |
| 171 | if clean != True: |
| 172 | json_data=open(scheme_file_path) |
| 173 | data = json.load(json_data) |
| 174 | if 'types' not in data: |
| 175 | print "couldn't find types object in json" |
| 176 | return |
| 177 | else: |
| 178 | types = readTypes(data['types']) |
| 179 | |
| 180 | db = MySQLdb.connect(user=dbSettings["user"],db=client_name,passwd=dbSettings["password"], host=dbSettings["host"]) |
| 181 | if clean == True: |
| 182 | clearUp(db) |
| 183 | print "Finished cleaning attributes successfully" |
| 184 | else: |
| 185 | addToDb(db, types) |
| 186 | f = open('dimensions.json','w') |
| 187 | outputDimensionsToFile(f,db) |
| 188 | |
| 189 | print 'Finished applying attributes successfully' |
| 190 | |
| 191 | json_data.close() |
| 192 | |