You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a PostgreSQL database that is not managed by Django. Tables are continuously added to it. You could think of it as a data lake or data warehouse.
I'd like to use the Django ORM to query these tables, but tables are inserted often enough that manage.py inspectdb to generate on-disk code is not practical. Instead, I'm thinking to hook into the internals of the Django inspection code to get the definition of a specific table (providing just the table name), and then use this package to dynamically create a model definition, allowing me to use the ORM on this model.
Has anyone done this before? Do you have any pointers on where to start, or things to note?
Also, if I don't want to store the dynamic models in the database, can I use ModelSchema and FieldSchema without saving the instances to the database?
The text was updated successfully, but these errors were encountered:
ecederstrand
changed the title
Create dynamic model by inspecting the database?
Create dynamic model for existing table by inspecting the database?
Nov 14, 2022
I have a PostgreSQL database that is not managed by Django. Tables are continuously added to it. You could think of it as a data lake or data warehouse.
I'd like to use the Django ORM to query these tables, but tables are inserted often enough that
manage.py inspectdb
to generate on-disk code is not practical. Instead, I'm thinking to hook into the internals of the Django inspection code to get the definition of a specific table (providing just the table name), and then use this package to dynamically create a model definition, allowing me to use the ORM on this model.Has anyone done this before? Do you have any pointers on where to start, or things to note?
Also, if I don't want to store the dynamic models in the database, can I use
ModelSchema
andFieldSchema
without saving the instances to the database?The text was updated successfully, but these errors were encountered: