dynamic-models | Example project demonstrating dynamic models in Django
kandi X-RAY | dynamic-models Summary
kandi X-RAY | dynamic-models Summary
Example project demonstrating dynamic models in Django
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dynamic-models
dynamic-models Key Features
dynamic-models Examples and Code Snippets
Community Discussions
Trending Discussions on dynamic-models
QUESTION
According to this issue – Dynamic Models in Phoenix Framework – it is possible to dynamically create a model in Elixir using Module.create
.
Is it also possible to create a table in the database for this model during runtime, i.e. without using Ecto migration files?
...ANSWER
Answered 2017-Dec-05 at 14:08PostgreSQL
and MySQL
adapters for Ecto
2.0+ have an ability to execute raw SQL:
QUESTION
Goal: Have a phoenix app (#1), that has empty (no tables) Postgres and on first boot waits to be further setup. Once it receives migration and model/schema files via http from other phoenix app (#2), it runs migrations, starts a supervisor(App1.Repo, []),
and all received models/schemas from app #2 puts in state in worker(App1.Models, [])
, so that app #1 can process queries like Repo.all(User)
. Then, app #1 listens for requests from the app #2 and performs changes in Postgres.
Reason: Idea is to isolate DB completely from app #2, so that when it needs something from db, it just sends Ecto
queries to app #1, and app #1 is able to perform that query and return a result. However, app #1 copy can be spawned for different apps, i.e. app #2, #3, #4, which all have different models/schemas, and on first connection provide their db settings (models/migrations) to app #1, which prepares its Postgres with those settings, and then just accept db queries.
Step 1: App #1 receives User
model and respective migration file from app #2.
Step 2: App #1 runs migration file to prepare Postgres.
Step 3: App #1 starts a GenServer (process?) with Ecto, Repo and newly received User
model from app #2 and listens for incoming requests.
Step 4: App #1 receives request, runs query, and returns list of all users in its db.
...ANSWER
Answered 2018-May-27 at 09:29Although I could hardly imagine a benefit of this architecture this is surely possible.
Sure, why not?
Use Ecto.Migrator
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dynamic-models
You can use dynamic-models like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page