Giter Site home page Giter Site logo

mysqlex's Introduction

Mysqlex

This is a wrapper around a newer mysql library for erlang:

https://github.com/mysql-otp

There are benchmarks for the mysql drivers:

Usage

To use add the following to your mix.exs:

def deps do
  [{:mysqlex, github: "tjheeta/mysqlex" } ]
end

Profit:

iex(8)> {:ok, pid} = Mysqlex.Connection.start_link(username: "test", database: "test", password: "test", hostname: "10.0.3.82")
{:ok, #PID<0.1420.0>}
iex(9)> Mysqlex.Connection.query(pid, "CREATE TABLE posts (id serial, title text)")
{:ok,
 %Mysqlex.Result{columns: [], command: :create, last_insert_id: 0, num_rows: 0,
  rows: []}}
iex(10)> Mysqlex.Connection.query(pid, "CREATE TABLE posts (id serial, title text)")
{:error,
 %Mysqlex.Error{message: "1050 - Table 'posts' already exists", mysqlex: nil}}
iex(11)> Mysqlex.Connection.query(pid, "INSERT INTO posts (title) VALUES ('my title')")
{:ok,
 %Mysqlex.Result{columns: [], command: :insert, last_insert_id: 1, num_rows: 1,
  rows: []}}
iex(12)> Mysqlex.Connection.query(pid, "SELECT title FROM posts", [])
{:ok,
 %Mysqlex.Result{columns: ["title"], command: :select, last_insert_id: nil,
  num_rows: 1, rows: [{"my title"}]}}
iex(13)> Mysqlex.Connection.query(pid, "SELECT id FROM posts WHERE title like ?", ["%my%"])
{:ok,
 %Mysqlex.Result{columns: ["id"], command: :select, last_insert_id: nil,
  num_rows: 1, rows: [{1}]}}

To use with ecto, you'll have to patch it for now:

https://gist.github.com/tjheeta/800deab2b9e7b2b9651b

mysqlex's People

Contributors

robotarmy avatar tjheeta avatar

Watchers

 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.