Skip to content
Advertisement

How to create ASC/DESC indexes using sqlalchemy?

I have the following table declaration

I need to create the following index:

CREATE INDEX ON dataset_updates(dataset_id, created_at DESC);

How can I specify DESC order?

Advertisement

Answer

Instead of referring to the columns as strings, refer to them as their actual (object) references and add the .desc() modifier as required:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement