Correct way to execute query in Django?

Asked

Viewed 50 times

1

I need to execute the query SELECT pg_database_size('mydatabase'), how do I do this in Django with the SGBD Postgres?

This is what I’ve tried

from django.db import connection

cursor = connection.cursor()
size = cursor.execute('''SELECT pg_database_size("mydatabase")''')

But the result of size is None.

How do I execute this query? The intention is to return the size of the database.

1 answer

0

In the official documentation of Django there are tutorials explaining how it is done and there are other websites with tutorials that Voce can learn.

Tutoral Django

Other tutorials

Browser other questions tagged

You are not signed in. Login or sign up in order to post.