A warpper for mysqlex to add connection pooling with poolboy
- Add
mysqlex_poolto your list of dependencies inmix.exs:
def deps do
[{:mysqlex_pool, "~> 0.1.0"}]
end- Ensure
mysqlex_poolis started before your application:
def application do
[applications: [:mysqlex_pool]]
endrun 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" )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 ] )You can set the configuration within your config.exs or just use the environment vars.
usernameBinarydefault:root: mysql user name. env-var:MYSQLEX_POOL_USERpasswordBinarydefault:root: mysql password. env-var:MYSQLEX_POOL_PASSWORDhostnameBinarydefault:127.0.0.1: mysql host. env-var:MYSQLEX_POOL_HOSTportIntegerdefault:3306: mysql port. env-var:MYSQLEX_POOL_PORTdatabaseBinarydefault:test: mysql datebase. env-var:MYSQLEX_POOL_DATABASEpool_sizeIntegerdefault:10: mysqlex/poolboy pool size. env-var:MYSQLEX_POOL_SIZEpool_overflowIntegerdefault:1: mysqlex/poolboy pool overflow. env-var:MYSQLEX_POOL_OVERFLOWcharsetBinarydefault:utf8: mysql charset. env-var:MYSQLEX_POOL_CHARSET
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.
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
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
| 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 |
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/mysqlex_pool.
|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|
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.