Git Product home page Git Product logo

mariaex's Introduction

Mariaex Build Status Coverage Status Deps Status

Usage

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

def deps do
  [{:mariaex, "~> 0.8.2"} ]
end

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

  iex(1)> {:ok, p} = Mariaex.start_link(username: "ecto", database: "ecto_test")
  {:ok, #PID<0.108.0>}

  iex(2)> Mariaex.query(p, "CREATE TABLE test1 (id serial, title text)")
  {:ok, %Mariaex.Result{columns: [], command: :create, num_rows: 0, rows: []}}

  iex(3)> Mariaex.query(p, "INSERT INTO test1 VALUES(1, 'test')")
  {:ok, %Mariaex.Result{columns: [], command: :insert, num_rows: 1, rows: []}}

  iex(4)> Mariaex.query(p, "INSERT INTO test1 VALUES(2, 'test2')")
  {:ok, %Mariaex.Result{columns: [], command: :insert, num_rows: 1, rows: []}}

  iex(5)> Mariaex.query(p, "SELECT id, title FROM test1")
  {:ok,
   %Mariaex.Result{columns: ["id", "title"], command: :select, num_rows: 2,
    rows: [[1, "test"], [2, "test2"]}}

Configuration

Important configuration, which depends on used charset for support unicode chars, see :binary_as in Mariaex.start_link/1

JSON library

As default, Poison is used for JSON library in mariaex to support JSON column.

If you want to use another library, please set config.exs like below.

config :mariaex, json_library: SomeLibrary

=======

Data representation

MySQL                 Elixir
----------            ------
NULL                  nil
TINYINT               42
INT                   42
BIGINT                42
FLOAT                 42.0
DOUBLE                42.0
DECIMAL               #Decimal<42.0> *
VARCHAR               "eric"
TEXT                  "eric"
BLOB                  <<42>>
DATE                  %Date{year: 2013, month: 10, day: 12}
TIME                  %Time{hour: 0, minute: 37, second: 14} **
YEAR                  2013
DATETIME              %DateTime{year: 2013 month: 10, day: 12, hour: 0, minute: 37, second: 14} **
TIMESTAMP             %DateTime{year: 2013 month: 10, day: 12, hour: 0, minute: 37, second: 14} **
BIT                   << 1 >>
GEOMETRY/POINT        %Mariaex.Geometry.Point{coordinates: {1.0, -1.0}, srid: 42}
GEOMETRY/LINESTRING   %Mariaex.Geometry.LineString{coordinates: [{0.0, 0.0}, {10.0, 10.0}, {20.0, 25.0}, {50.0, 60.0}], srid: 0}
GEOMETRY/POLYGON      %Mariaex.Geometry.Polygon{coordinates: [[{0.0, 0.0}, {10.0, 0.0}, {10.0, 10.0}, {0.0, 10.0}, {0.0, 0.0}], [{5.0, 5.0}, {7.0, 5.0}, {7.0, 7.0}, {5.0, 7.0}, {5.0, 5.0}]], srid: 0}

mariaex's People

Contributors

liveforeverx avatar fishcakez avatar jeroenbourgois avatar laurocaetano avatar hashijun avatar umatomba avatar archan937 avatar pierot avatar surik avatar iaddict avatar josevalim avatar gjaldon avatar nakagami avatar chvanikoff avatar 0xax avatar rodrigues avatar rodrigodealer avatar m13m avatar kpanic avatar andrewdryga avatar whatyouhide avatar bigcurl avatar ersoy78 avatar edmz avatar wojtekmach avatar scohen avatar rutan avatar rrrene avatar michalmuskala avatar mtokioka avatar

Watchers

 avatar  avatar 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.