-1
I have a Python script that reads messages coming from the serial port. When reading messages, record them in a mailing list and send them to a SQLITE3 database. However, when executing, it presents the following error:
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 5, and there are 1 supplied`
  import sqlite3
    conn = sqlite3.connect(database='dados.db')``
conn = sqlite3.connect(database='dados.db')
cursor = conn.cursor()
cursor.execute("""
                  CREATE TABLE dados (
                  titutlo TEXT NOT NULL,
                  command INTEGER NOT NULL,
                  tipo_dispositivo INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                  id_dispositivo TEXT NOT NULL,
                  distancia INTEGER,
                  contador     VARCHAR(11) NOT NULL,
                  data  INTEGER NOT NULL
                  );
                  """)
while True: 
        command = [ser.readline().decode('utf-8').split('|')] # O decode() aqui é para converter de bytes para string         
        if  command!= '': 
         #   print(command)
            cursor.executemany("""
            INSERT INTO dados(tipo_dispositivo, id_dispositivo, distancia,contador,data)
            VALUES(?,?,?,?,?)""", command)
            conn.commit()
            #print(lista)
conn.close()`
Still I could not solve. I am filling the table through the data that the script receives in the serial port and not from a file . txt The command ser.readline() reads the serial port (which is an Arduino sensor sending some messages). I use . split() to ignore '|' that separate the data and I want to save everything in a list, only to send it to the database, and each new line, a new sensor reading, understands?
– Guilherme Dinamarco
@Guilhermedinamarco Ops! Following edition!
– Lacobus