Hi ElixirCommunity,
We have a data-centric elixir project.
Currenlty we are using ecto-3
, ecto_sql
with postgres
and oracle
.
We need to fetch a lot of data from mssql
but currently there is no adapter ready for ecto-3
.
However, there is an adapter which relies on ecto-2
and support mssql
.
Is there any way to use that adapter in same project ?
If not, what is the best way to fetch data from MSSQL database and use that data for api-calls or transferring that data to other dbs.
If you want to connect to MSSQL, this article may be of relevance to you: https://github.com/findmypast-oss/mssqlex
Once you have a driver that works in place, there are many things you can do. Recently I just heard in Elixir Mix Daniel Serrano using Flow to read in parallel from a DB .
Link to Flow
I also know some people like GraphQL and the author of https://pragprog.com/book/wwgraphql/craft-graphql-apis-in-elixir-with-absinthe is rather active in this forum, as well as a really nice guy too ! (which I could remember his username, i’m sure someone will!)
So you have quite a number of options, it all depends on how much time you’re wiling to invest.
1 Like
The author of the graphql book is @benwilson512
1 Like
Thanks for reply @Fl4m3Ph03n1x ,
Our current apis are graphql-apis only It’s great.
The only problem we are facing is - how to make mssql work!!!
One possible option is to downgrade everything to ecto-2
which doesn’t feel right
And I’m unable to make adapter work with ecto-3
and ecto-sql
Any example implementation or reference about ecto-sql
and mssql
or tds
would help a lot.
We don’t use mssql here nor ecto, so I am afraid I can’t be of much help. I did find a couple of articles that may help you out:
https://medium.com/asolvi/going-functional-part-iii-using-elixir-and-ecto-with-azure-sql-4e66b677f998
https://medium.com/asolvi/update-azure-sql-with-elixir-c77da7cc4197 (updated version of the first article, but the journey is what matters!)
If this still doesn’t help, I recommend you create an issue in the github projects and ask the authors for some guidance or examples.
Reading the test files usually helps as well:
defmodule Mssqlex.QueryTest do
use ExUnit.Case, async: true
alias Mssqlex.Result
setup_all do
{:ok, pid} = Mssqlex.start_link([])
Mssqlex.query!(pid, "DROP DATABASE IF EXISTS query_test;", [])
{:ok, _, _} = Mssqlex.query(pid, "CREATE DATABASE query_test;", [])
{:ok, [pid: pid]}
end
test "simple select", %{pid: pid} do
assert {:ok, _, %Result{}} =
Mssqlex.query(
pid,
"CREATE TABLE query_test.dbo.simple_select (name varchar(50));",
[]
)
This file has been truncated. show original