X
X
xxxfdd2021-04-16 01:38:56
Python
xxxfdd, 2021-04-16 01:38:56

Why writes NULL value in the "id" column if primar key?

6078c27441bbf816336447.pngI gave the column an ​​id Promary key and here I just add data to the table without specifying the id because it should fill in on its own, but it does not fill in, what's the matter?

f"""INSERT INTO {table} (name, user_name, shop, phone, price, bazar_tovar, oplata, clock, pay, id_user) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
                            (Devet_pm[3], Devet_pm[4], Devet_pm[5], phone, Devet_pm[7], Devet_pm[2], Devet_pm[11], a,
                             ass, user_id_start,))<img src="https://habrastorage.org/webt/60/78/c0/6078c07eacd1a089309796.png" alt="image"/>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2021-04-16
@xxxfdd

primary key and is not required to "fill itself" in any database. Even in mysql this is a separate feature - auto_increment. And here you need sequence or serial for this. See for example here: https://www.postgresqltutorial.com/postgresql-serial/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question