MssqlEcto
Installation
Erlang ODBC Application
MssqlEcto requires the Erlang ODBC application to be installed. This might require the installation of an additional package depending on how you have installed Elixir/Erlang (e.g. on Ubuntu sudo apt-get install erlang-odbc
).
Microsoft’s ODBC Driver
MssqlEcto depends on Microsoft’s ODBC Driver for SQL Server. You can find installation instructions for Linux or other platforms on the official site.
Hex
This package is availabe in Hex, the package can be installed by adding mssql_ecto
to your list of dependencies in mix.exs
:
def deps do
[{:mssql_ecto, "~> 0.1"}]
end
If you are running an Elixir version below 1.4 or you have the applcations
key set in your application options, you will also need to update your list of running applications:
def application do
[applications: [:logger, :mssql_ecto, :ecto]]
end
Configuration
Example configuration:
config :my_app, MyApp.Repo,
adapter: MssqlEcto,
database: "sql_server_db",
username: "bob",
password: "mySecurePa$$word",
hostname: "localhost"
Type Mappings
Ecto Type | SQL Server Type | Caveats |
---|---|---|
:id | int | |
:serial | int identity(1, 1) | |
:binary_id | char(36) | |
:uuid | char(36) | |
:string | nvarchar | |
:binary | nvarchar(4000) | Limited size, not fully implemented |
:integer | int | |
:boolean | bit | |
{:array, type} | list of type | Not Supported |
:map | nvarchar(4000) | Not Supported |
{:map, _} | nvarchar(4000) | Not Supported |
:date | date | |
:time | time | Can write but can’t read |
:utc_datetime | datetime2 | |
:naive_datetime | datetime2 | |
:float | float | |
:decimal | decimal |
Features not yet implemented
- Table comments
- Column comments
- On conflict
- Upserts