[Fixed]-My Python web crawler loop thru a list but writes over and over in the same field in my SQL Database

1👍

You created an object tabelle = Companies(). An instance of a model class represents a row in the DB. You have to create the object inside the loop (https://docs.djangoproject.com/en/1.10/topics/db/queries/#creating-objects).

for brand in brandLst:
    tabelle = Companies()
    tabelle.companyname = brand
    tabelle.comfair = 0
    tabelle.comecological = 0
    print(tabelle.companyname, tabelle.comfair, tabelle.comecological)
    tabelle.saveCompany()
    print("Saved")

Leave a comment