S
S
stayHARD2015-08-29 13:49:10
PostgreSQL
stayHARD, 2015-08-29 13:49:10

How to properly update postgresql?

Hello.
How to do something after updating the records in the database, the order of the records did not change.
Now I'm doing this:

import psycopg2
connection = psycopg2.connect(database = "contacts", user = "???", password = "???", host="localhost", port="5432")
c = connection.cursor()
.....
query = "UPDATE app_contacts SET url = %s, seen = %s WHERE id = %s;"
data = (website, "1", item[0])
c.execute(query, data)

Everything is fine, but the order of the records has changed. I look through pgadmin3.
How to avoid it?
To obtain
1
2
3
...
N

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2015-08-29
@stayHARD

When reading, use order by.
While there is no order by, according to the SQL standard itself, the order of rows is not defined.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question