Reputation: 47
Came across this link regarding use of Ecto. Elixir ecto connect to an existing DB . Schemas are already created in a database so why declare here? We use stmt like Ecto.Adapters.SQL.query when using odbc/jdbc/odac drivers and are less complicated and straightforward.
So where do give the stmt: Ecto.Adapters.SQL.query(YourRepo, "SELECT $1", [1])?
Is it in web/models/abc.ex?
And how do you get back the results?
Can you pl mention some of benefits you get from Ecto that use of direct SQL does'nt provide?
Upvotes: 0
Views: 1027
Reputation: 933
It sounds like Ecto might not be the best fit for what you're trying to do with it. Ecto is great for new projects where you can start with it from scratch using migrations and building the schemas up in the system as you go. For hooking up to an existing database, it can get a little tedious as you're trying to remap all of the existing items though.
Luckily, you're not tied to Ecto if it doesn't meet your needs. You might want to give something like Moebius a try since it seems to take exactly the approach that you're looking for.
Moebius is not an ORM. There are no mappings, no schemas, no migrations; only queries and data. We embrace PostgreSQL as much as possible, surfacing the goodness so you be a hero.
https://github.com/robconery/moebius
Upvotes: 3
Reputation: 2311
Could you please edit your question with a more elaborate and detailed description and content, please?
About the benefits:
Upvotes: 3