Answer the question
In order to leave comments, you need to log in
Why are the actions of the program with the database not saved?
There is a program
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question