1

I have code with following insert statement.

cursor = self.conn.cursor()
        print("New config with values: {0}, {1}".format(self.scale_factor, self.min_neighbours))
        cursor.execute("INSERT INTO config(scale_factor, min_neighbours) VALUES(?,?)", float(self.scale_factor), int(self.min_neighbours))
        self.conn.commit()
        record_id = cursor.execute('SELECT @@IDENTITY AS id;').fetchone()[0]
        if record_id:
            self.id = record_id
            print("Insertion succesfull. Generated id: {0}".format(record_id))
        else:
            print("Insertion failed.")

Insert is successful but no data are inserted except identity column.

Program output:

New config with values: 0, 0.08
Config insertion succesfull. Inserted id: 176

Select from table:

id  | scale_factor | min_neighbours
176 | 0.0000       |    0

Insert from SQL Profiler:

INSERT INTO config(scale_factor, min_neighbours) VALUES(0.0,0)

Does anyone have any idea why those values are zero? I'm new to the python.

Michalides
  • 152
  • 1
  • 8

0 Answers0