T
T
timkin12018-07-20 21:55:25
Python
timkin1, 2018-07-20 21:55:25

Records are not being added to SQLite, what is the reason for this?

Hello!
I'm trying to connect a table to a Python program in order to add data through it, but for some reason it works without errors, although data is not added, here is a code snippet:

connection = sqlite3.connect('bd/teachers.db')
    teachers = connection.cursor()
    name = str(input('Имя\n'))
    about = str(input('Описание\n'))
    table = str(input('таблица\n'))
    ins = 'INSERT INTO {} VALUES(NULL,?,?,?)'.format(table)
    print(ins)
    teachers.execute(ins, (name, about, des))

The table consists of 4 columns - int (id) and 3 text
PS id - an auto-incrementing field, how can it be ignored when adding a record through the program?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-07-20
@timkin1

First, you can specify which fields you insert
Secondly, the data will not be saved to the database unless the transaction is committed by calling the commit method .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question