{"id":13508919,"url":"https://github.com/livehelpnow/tds_ecto","last_synced_at":"2025-10-21T14:59:02.055Z","repository":{"id":27243270,"uuid":"30715294","full_name":"livehelpnow/tds_ecto","owner":"livehelpnow","description":"TDS Adapter for Ecto","archived":false,"fork":false,"pushed_at":"2020-03-03T15:35:23.000Z","size":384,"stargazers_count":57,"open_issues_count":8,"forks_count":34,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-20T17:52:28.712Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/livehelpnow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-12T17:49:24.000Z","updated_at":"2023-09-01T08:47:40.000Z","dependencies_parsed_at":"2022-07-25T17:20:08.058Z","dependency_job_id":null,"html_url":"https://github.com/livehelpnow/tds_ecto","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livehelpnow%2Ftds_ecto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livehelpnow%2Ftds_ecto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livehelpnow%2Ftds_ecto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livehelpnow%2Ftds_ecto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/livehelpnow","download_url":"https://codeload.github.com/livehelpnow/tds_ecto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246314042,"owners_count":20757455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:01:00.452Z","updated_at":"2025-10-21T14:59:01.963Z","avatar_url":"https://github.com/livehelpnow.png","language":"Elixir","funding_links":[],"categories":["ORM and Datamapping"],"sub_categories":[],"readme":"# Tds.Ecto (Ecto v2)\n\nMSSQL / TDS Adapter for Ecto2\n\n[![Build Status][appveyor-img]][appveyor] [![Hex Version][hex-img]][hex]\n\n[appveyor-img]: https://ci.appveyor.com/api/projects/status/g59ocaellinuig7g?svg=true\n[appveyor]: https://ci.appveyor.com/project/mjaric/tds-ecto-jpd3h\n[hex-img]: https://img.shields.io/hexpm/v/tds_ecto.svg\n[hex]: https://hex.pm/packages/tds_ecto\n\n## Example\n```elixir\n# In your config/config.exs file add MSSQL connection options\n# By default it use port 1433, different port can be specified with\n# port: 1434\n# option and named instance with\n# instance: \"instance_name\"\nconfig :my_app, Repo,\n  database: \"ecto_simple\",\n  username: \"mssql\",\n  password: \"mssql\",\n  hostname: \"localhost\"\n\n# In your application code\ndefmodule Repo do\n  use Ecto.Repo,\n    otp_app: :my_app,\n    adapter: Tds.Ecto\nend\n\ndefmodule Weather do\n  use Ecto.Schema\n\n  schema \"weather\" do\n    field :city     # Defaults to type :string\n    field :temp_lo, :integer\n    field :temp_hi, :integer\n    field :prcp,    :float, default: 0.0\n  end\nend\n\ndefmodule Simple do\n  import Ecto.Query\n\n  def sample_query do\n    query = from w in Weather,\n          where: w.prcp \u003e 0 or is_nil(w.prcp),\n         select: w\n    Repo.all(query)\n  end\nend\n```\n\nAlso, if you need to map table to schema other than [dbo], simple use @schema_prefix \"your_schema\", eg:\n\n```\ndefmodule Invoices.Invoice do\n  use Ecto.Schema\n\n  @schema_prefix :invoices\n  schema \"invoices\" do\n    field :due_date, :datetime\n    field :sum, :float\n  end\nend\n```\n\n## Usage\n\nAdd Tds as a dependency in your `mix.exs` file.\n\n```elixir\ndef deps do\n  [{:tds_ecto, \"~\u003e 2.2\"}]\nend\n```\n\nYou should also update your applications list to include both projects:\n```elixir\ndef application do\n  [applications: [:logger, :tds_ecto, :ecto]]\nend\n```\n\nTo use the adapter in your repo:\n```elixir\ndefmodule MyApp.Repo do\n  use Ecto.Repo,\n    otp_app: :my_app,\n    adapter: Tds.Ecto\nend\n```\n\ntds_ecto relies on pattern matching against error messages to extract constraint names.\nIf your SQL server is not configured to English as its default language you may add an `after_connect` hook to your repo and set English as the language for Ecto connections.\n\n```elixir\ndef after_connect(conn) do\n  Tds.Ecto.Connection.query(conn, \"SET LANGUAGE English\", [], [])\nend\n```\n\nFor additional information on usage please see the documentation for [Ecto](http://hexdocs.pm/ecto).\n\n## Data Type Mapping\n\n    MSSQL             \tEcto/Tds.Ecto\n    ----------        \t------\n    nvarchar            :string\n    varchar             Tds.VarChar\n    char                :binary\n    varbinary           :binary\n    float               :float\n    decimal             :decimal\n    integer             :integer\n    bit                 :boolean\n    uniqueidentifier    :uuid\n    datetime            :datetime\n    date                :date\n    time                :time\n\n\n\n## Contributing\n\nTo contribute you need to compile Tds from source and test it:\n\n```\n$ git clone https://github.com/livehelpnow/tds_ecto.git\n$ cd tds_ecto\n$ mix test\n```\n\nTests will try to connect to `localhost` using `sa` as username with predefined password `mssql`, but you can set environment variables to override any, like so: `SQL_USERNAME=myuser; SQL_PASSWORD=mypassword; SQL_HOSTNAME=sqlserver.local; mix test` or if you are using windows then `SET SQL_USERNAME=myuser \u0026\u0026 SET SQL_PASSWORD=mypassword \u0026\u0026 SET SQL_HOSTNAME=sqlserver.local \u0026\u0026 mix test`. Please note that tests will run againes default sql server instance.\n\nAdditionally SQL authentication needs to be used for connecting and testing.If you override default test settings, make sure either that yor user has sysadmin privilegies to add the user `test_user` with access to the database `test_db`, or simply add manualy test_user on your server. See one of the test files for the connection information and port number.\n\n## License\n\n   Copyright 2014, 2015, 2016, 2017 LiveHelpNow\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivehelpnow%2Ftds_ecto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivehelpnow%2Ftds_ecto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivehelpnow%2Ftds_ecto/lists"}