0

i am using sqlite3 in python and whenever i insert data it replace it with the data in the DB instead of adding rows

i couldn't have more than one row..

--

    def success(self):
        global cursor, conn
        wallet = random.randint(1000000000, 9999999999)
        if self.checkID:
            query = [self.fNEntry.get(), self.lNEntry.get(), self.idEntry.get(), self.pwEntry.get(), self.emEntry.get(),
                     self.pNEntry.get(), wallet, 1000]
            cursor = conn.execute('INSERT INTO STUDENTS(FNAME, LNAME, ID, PASSWORD, EMAIL, PHONE, WALLET, BALANCE) \
        VALUES(?, ?, ?, ?, ?, ?, ?, ?);', query)
conn.commit()
Sultan
  • 1
  • 1
  • Try to print the query as a string and manually insert into SQLite. Or try to catch [any error](https://stackoverflow.com/questions/25371636/how-to-get-sqlite-result-error-codes-in-python#38847510). [More examples here](https://www.programcreek.com/python/example/14834/sqlite3.DatabaseError). – MyICQ May 09 '22 at 06:56
  • Do you have an auto-increment id column when creating your table? – Jagar May 09 '22 at 11:07
  • Can we see the DDL for the table (the CREATE TABLE code)? If you have a primary key, then possibly you are attempting to insert another row with the same primary key. An auto-increment primary key would help with that. – MatthewMartin May 15 '22 at 02:15

0 Answers0