GithubHelp home page GithubHelp logo

mpneuried / mysqlex_pool Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 116 KB

A warpper for mysqlex to add connection pooling with poolboy

License: Other

Elixir 95.43% Makefile 3.45% Shell 1.12%
elixir mysql mariadb pool poolboy connection-pool connection wrapper

mysqlex_pool's Introduction

MysqlexPool

Travis Build Status Windows Tests Coveralls Coverage

Hex.pm Version Deps Status Hex.pm

A warpper for mysqlex to add connection pooling with poolboy

Installation

  1. Add mysqlex_pool to your list of dependencies in mix.exs:
def deps do
  [{:mysqlex_pool, "~> 0.1.0"}]
end
  1. Ensure mysqlex_pool is started before your application:
def application do
  [applications: [:mysqlex_pool]]
end

Usage

MysqlexPool.query/1

run a simple mysql query - query/1

{ :ok, %Mysqlex.Result{...} } = MysqlexPool.query( "SELECT * FROM test" )

Example:

{ :ok, %Mysqlex.Result{columns: ["ID", "Name"], command: :select, last_insert_id: nil, num_rows: 1, rows: [{1, "Kabul"}] } } = MysqlexPool.query( "SELECT ID, Name FROM `city` WHERE id = 1" )

MysqlexPool.query/2

run a mysql query with param substitution - query/2

{ :ok, %Mysqlex.Result{...} } = MysqlexPool.query( "SELECT * FROM test WHERE id = ?", [ 1337 ] )

Example:

{ :ok, %Mysqlex.Result{columns: ["ID", "Name"], command: :select, last_insert_id: nil, num_rows: 1, rows: [{1, "Kabul"}] } } = MysqlexPool.query( "SELECT ID, Name FROM `city` WHERE id = ?", [ 1 ] )

Config

You can set the configuration within your config.exs or just use the environment vars.

  • username Binary default: root: mysql user name. env-var: MYSQLEX_POOL_USER
  • password Binary default: root: mysql password. env-var: MYSQLEX_POOL_PASSWORD
  • hostname Binary default: 127.0.0.1: mysql host. env-var: MYSQLEX_POOL_HOST
  • port Integer default: 3306: mysql port. env-var: MYSQLEX_POOL_PORT
  • database Binary default: test: mysql datebase. env-var: MYSQLEX_POOL_DATABASE
  • pool_size Integer default: 10: mysqlex/poolboy pool size. env-var: MYSQLEX_POOL_SIZE
  • pool_overflow Integer default: 1: mysqlex/poolboy pool overflow. env-var: MYSQLEX_POOL_OVERFLOW
  • charset Binary default: utf8: mysql charset. env-var: MYSQLEX_POOL_CHARSET

Development & Benchmarks

All examples and tests are based on the example db world. You can find a copy here or use the official source and download the world database.

Development

To run the tests just call: make test or make t.

In this case it'll use the environment in test.env. To use your own just copy it and use make test=my_custom_test.env test

Benchmarks

To run the benchmaks just call: make bench or make b.

In this case it'll use the environment in test.env. To use your own just copy it and use make test=my_custom_test.env test

Release History

Version Date Description
0.2.1 2018-01-25 Updated dependencies
0.2.0 2017-03-17 added configuration, added docs, fixed travis and appveyor ci configs.
0.1.0 2017-03-16 initial wip version

Infos

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/mysqlex_pool.

Other projects

|Name|Type|Description| |:--|:--| |ex-redis-sessions|Elixir|An advanced session store for Elixir and NodeJS based on Redis | |mpneuried/docker_distillery|Docker Image|Create a docker container to be able to build elixir releases via distillery on different os's.| |mpneuried/elixir-alpine|Docker Image|A minimal docker container to run elixir| |redis-sessions|Node.JS|An advanced session store for NodeJS and Redis| |node-cache|Node.JS|Simple and fast NodeJS internal caching. Node internal in memory cache like memcached.| |rsmq|Node.JS|A really simple message queue based on redis| |obj-schema|Node.JS|Simple module to validate an object by a predefined schema|

The MIT License (MIT)

Copyright © 2017 M. Peter, http://www.tcs.de

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mysqlex_pool's People

Contributors

mpneuried avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nickkeers

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.