Coder Social home page Coder Social logo

tds's Introduction

Tds

MSSQL / TDS Database driver for Elixir.

Usage

Add Tds as a dependency in your mix.exs file.

def deps do
  [{:tds, "~> 0.2"} ]
end

After you are done, run mix deps.get in your shell to fetch and compile Tds. Start an interactive Elixir shell with iex -S mix.

iex> {:ok, pid} = Tds.Connection.start_link([hostname: "localhost", username: "test_user", password: "test_password", database: "test_db", port: 4000])
{:ok, #PID<0.69.0>}
iex> Tds.Connection.query!(pid, "SELECT 'Some Awesome Text' AS MyColumn", [])
%Tds.Result{columns: ["MyColumn"], rows: [{"Some Awesome Text"}], num_rows: 1}}
iex> Tds.Connection.query!(pid, "INSERT INTO MyTable (MyColumn) VALUES (@my_value)", [%Tds.Parameter{name: "@my_value", value: "My Actual Value"}])
%Tds.Result{columns: nil, rows: nil, num_rows: 1}}

Features

  • Automatic decoding and encoding of Elixir values to and from MSSQL's binary format
  • Supports TDS Version 7.3, 7.4

Connecting to SQL Instances

Tds Supports sql instances by passing instance: "instancename" to the connection options.

Data representation

TDS             Elixir
----------      ------
NULL            nil
bool            true | false
char            "é"
int             42
float           42.0
text            "text"
binary          <<42>>
numeric         #Decimal<42.0> *
date            {2013, 10, 12}
time            {0, 37, 14}
datetime	      {{2013, 10, 12}, {0, 37, 14}}
uuid            <<160,238,188,153,156,11,78,248,187,109,107,185,189,56,10,17>>

All data types will be supported, unsupported types currently are udt, xml

Contributing

To contribute you need to compile Tds from source and test it:

$ git clone https://github.com/livehelpnow/tds.git
$ cd tds
$ mix test

The tests require an addition to your hosts file to connect to your sql server database.

sqlserver.local

Additionally SQL authentication needs to be used for connecting and testing. Add the user "mssql" with password "mssql" as owner to the database "test". See one of the test files for the connection information and port number.

##Special Thanks

Thanks to ericmj, this driver takes a lot of inspiration from postgrex. https://github.com/ericmj/

Also thanks to everyone in the Elixir Gogle group and on the Elixir IRC Channel

License

Copyright 2014, 2015 LiveHelpNow

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

tds's People

Contributors

mobileoverlord avatar swsch avatar

Watchers

Daniel Turner avatar

Forkers

jnyinglis

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.