Есть программа
import psycopg2
connection = psycopg2.connect(host="localhost", user="postgres", password="password")
cursor = connection.cursor()
if True:
cursor.execute("""CREATE TABLE products (id serial PRIMARY KEY,name varchar (40) NOT NULL, description varchar (255) NOT NULL, attachments varchar (255) NOT NULL, selled serial, author_id serial NOT NULL, customer serial, checher serial NOT NULL);""")
commands = [
"INSERT INTO products (name, description, attachments, selled, author_id, customer, checher) VALUES ('Its Product', 'Its description', 'Its attachments', 0, 1, 0, 0)",
"SELECT * FROM products",
]
for i in range(3):
for query in range(len(commands)):
cursor.execute(commands[query])
try:
data = cursor.fetchall()
print(i+1)
for _ in data:
print(" ",_)
except:
continue
Почему после выполнения этого кода все действия с таблицей, которые тут происходили, отменяются?