K
K
Konstantin Malyarov2019-07-06 00:03:02
Python
Konstantin Malyarov, 2019-07-06 00:03:02

INSERT psycopg2 error occurs?

def set_user_info(id, fio, phone, registration):
    conn = try_connect()
    cursor = conn.cursor()
    try:
        cursor.execute(
            "INSERT INTO user_info (id, fio, phone, registration) "
            "VALUES (%d, %s, %s, TRUE)", (id, fio, phone, registration))
        conn.commit()
        conn.close()
        cursor.close()
        print('Запись user создана')
    except:
        print('Ошибка создания записи user')
    print('Завершение создания записи user')

print() outputs:
INSERT INTO user_info (id, fio, phone, registration) VALUES (477100779, 'Ivanov Ivan Ivanovich', '+79991234567', FALSE)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question