SQLite & Python - 3 - Insert Into Table

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

I may be a bit late on this but whenever i run the code to insert values into the data base it says that it all goes through but when i refresh the db file in sqlite studio nothing appears

scubamicrowave
Автор

import sqlite3

try:

conn =



sql = """INSERT INTO login
(username, password)
VALUES ('john', 'smith');"""

cursor = conn.cursor()
cursor.execute(sql)
conn.commit
print("Inserted data")
cursor.close()

except sqlite3.Error as e:
print("Error with inserting data", e)

finally:
if (conn):
conn.close()
print("connection closed")



(That is my code)^

scubamicrowave