Giter Club home page Giter Club logo

mssql_ecto's Introduction

MssqlEcto

Build Status Coverage Status Inline docs Ebert Hex.pm LICENSE

Ecto Adapter for Mssqlex

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

If you are using application inference, i.e. application in your mix.exs looks something like this:

def application do
  [extra_applications: [:logger]]
end

Note, the lack of :applications key. Then, you just need to add the following dependencies:

def deps do
  [{:mssql_ecto, "~> 1.1.0"},
   {:mssqlex, "~> 1.0.0"}]
end

If you are explicitly calling out all running applications under application in your mix.exs, i.e. it looks something like this:

def application do
  [applications: [:logger, :plug, :postgrex]]
end

Then, you need to add mssql_ecto and mssqlex to both your deps and list of running applications:

def application do
  [applications: [:logger, :plug, :mssqlex, :mssql_ecto]]
end

def deps do
  [{:mssql_ecto, "~> 1.1.0"},
   {:mssqlex, "~> 1.0.0"}]
end

Configuration

Example configuration:

config :my_app, MyApp.Repo,
  adapter: MssqlEcto,
  database: "sql_server_db",
  username: "bob",
  password: "mySecurePa$$word",
  hostname: "localhost",
  instance_name: "MSSQLSERVER",
  port: "1433"

Example Project

An example project using mssql_ecto with Docker has kindly been created by Chase Pursłey. It can be viewed here.

Type Mappings

Ecto Type SQL Server Type Caveats
:id int
:serial int identity(1, 1)
:bigserial bigint identity(1,1) When a query is returning this value with the returning syntax and no schema is used, it will be returned as a string rather than an integer value
: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

Contributing

Code of Conduct

This project had a Code of Conduct if you wish to contribute to this project, please abide by its rules.

mssql_ecto's People

Contributors

toddharding avatar teehuhta avatar shdblowers avatar drueck avatar ghouli avatar redlightmikey avatar cdesch avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.