I am loading the json data into database created by SQLAlchemy:
with open('test_data.json') as f:
data=f.read()
jsondata=json.loads(data)
for row in jsondata['rows']:
r = Review(row['business_id'])
session.add(r)
session.commit()
I am storing the business id of json file into business_id column but i always get an integrity error of this sort:
sqlalchemy.exc.IntegrityError: (IntegrityError) column business_id is not unique u'INSERT INTO rev (business_id) VALUES (?)' (u'vcNAWiLM4dR7D2nwwJ7RPCA',)
You are trying to insert a value that already exists into the the column
business_idwhich has been marked as unique. Every row need to have a unique value in this field.