Opened 6 years ago

Closed 6 years ago

#30369 closed New feature (wontfix)

Creating database tables from queries based on ORM API

Reported by: Markus Elfring Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: database tables, queries, ORM, API, SQL, storage management, object-relational mapping, computation results, CTAS
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Value combinations can be counted in records also together with the software “Django 2.2” by database services.
I am looking for ways to store a computation result into a dynamically generated table.

Change History (5)

comment:1 by Mariusz Felisiak, 6 years ago

Version: 2.2master

I don't think that we will support CREATE TABLE AS SELECT. In your use case I would create MATERIALIZED VIEW (or VIEW) in a migrations with raw SQL. Such views can be introspected automatically (see inspectdb) and used via Django ORM (see managed option).

in reply to:  1 ; comment:2 by Markus Elfring, 6 years ago

Replying to felixxm:

  • Does the functionality “materialized view” provide run time characteristics which are similar to the CTAS command?
  • Does it belong to the SQL standard?
  • The support for it varied between databases over time. How will the software evolve further in this area?

in reply to:  2 ; comment:3 by Mariusz Felisiak, 6 years ago

Resolution: wontfix
Status: newclosed
  • Does the functionality “materialized view” provide run time characteristics which are similar to the CTAS command?

Yes it is quite similar, db will recognize column types.

  • Does it belong to the SQL standard?

I'm not sure, but I don't think so.

  • The support for it varied between databases over time.

Materialized views are supported on PostgreSQL and Oracle.

  • How will the software evolve further in this area?

Do you mean by databases? I don't know answer for such existential question :)

Please use one of support channels if you have other support questions related with Django. If you have questions about databases you should probably ask somewhere else e.g. on StackOverflow.

in reply to:  3 comment:4 by Markus Elfring, 6 years ago

Resolution: wontfix
Status: closednew

Replying to felixxm:

I'm not sure, but I don't think so.

I would find the support for the SQL standard statement “CREATE TABLE AS SELECT” (CTAS) nicer (while working with materialized views can be similarly useful).

comment:5 by Mariusz Felisiak, 6 years ago

Resolution: wontfix
Status: newclosed

Please start a new thread on `django-developers` if you really think that support for CREATE TABLE AS SELECT should be added to the Django ORM. IMO use case is really narrow because even if you will create such table in ORM it will be tricky to make it accessible via ORM.

We can reopen this ticket if we reach consensus on django-developers.

Note: See TracTickets for help on using tickets.
Back to Top