Giter Site home page Giter Site logo

bank_mysql's People

Contributors

essen avatar teburd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bank_mysql's Issues

no match error in parse_handshake_init/1

Hi!

This no match happens if the MySQL server doesn't send the auth-plugin in the initial_handshake packet.

You can find a fix here: https://github.com/pannonia-technologies/bank_mysql/commit/703d39d792964b4a3b89af087d8f6fb3205ac263

Sorry, the fix above is broken... damn, just too late at night again ;-). So you also need the fix of the fix commit: https://github.com/pannonia-technologies/bank_mysql/commit/8b06ed55d5636ce9ddb233140d1d09458176e4f5

'matthias'.

added support for MySQL decimal and numeric

Hi,

please review the code and tell me what you think about it.

https://github.com/pannonia-technologies/bank_mysql/commit/ce82b146e257bf77a2c3b65579ec0f68cbf46179

Please tell me if you want me to send a pull request. I'll then make the change to current HEAD.

Usage example in the shell:

159> bank:prepare(test_db, insert_t3, "INSERT INTO t3 (amount) VALUES (?)").
ok
160> bank:prepare(test_db, select_t3, "SELECT * FROM t3").                  
ok
161> bank:execute(test_db, insert_t3, [{decimal, 12000, 5}]).               
{ok,1,13}
162> bank:execute(test_db, select_t3, []).                                  
{rows,[[{<<"id">>,1},{<<"amount">>,{decimal,3333350000,5}}],
       [{<<"id">>,2},{<<"amount">>,{decimal,9999999999,5}}],
       [{<<"id">>,3},{<<"amount">>,{decimal,1000000000,5}}],
       [{<<"id">>,4},{<<"amount">>,null}],
       [{<<"id">>,5},{<<"amount">>,{decimal,-100000,5}}],
       [{<<"id">>,6},{<<"amount">>,{decimal,-1,5}}],
       [{<<"id">>,7},{<<"amount">>,{decimal,0,5}}],
       [{<<"id">>,8},{<<"amount">>,{decimal,-1,5}}],
       [{<<"id">>,9},{<<"amount">>,{decimal,-1000000,5}}],
       [{<<"id">>,10},{<<"amount">>,{decimal,-100000,5}}],
       [{<<"id">>,11},{<<"amount">>,{decimal,-10000,5}}],
       [{<<"id">>,12},{<<"amount">>,{decimal,-10000,5}}],
       [{<<"id">>,13},{<<"amount">>,{decimal,12000,5}}]]}

This is when you query MySQL directly:

mysql> select * from t3;
+----+-------------+
| id | amount      |
+----+-------------+
|  1 | 33333.50000 |
|  2 | 99999.99999 |
|  3 | 10000.00000 |
|  4 |        NULL |
|  5 |    -1.00000 |
|  6 |    -0.00001 |
|  7 |     0.00000 |
|  8 |    -0.00001 |
|  9 |   -10.00000 |
| 10 |    -1.00000 |
| 11 |    -0.10000 |
| 12 |    -0.10000 |
| 13 |     0.12000 |
+----+-------------+
13 rows in set (0.00 sec)

'matthias'.

Changing connect function to support more options

Hi,

it would be nice, to change the connect function, so an arbitrary number of parameters can be passed. This would also eliminate the need for an init_fun in bank.

This would be helpful, i.e. when you want to pass in the desired charset and collation upon connect. Or once transaction support is completed, you could pass in if you like to have auto commit set or not.

whatever() ->
  ConnectParams = [
    {driver, bank_mysql},
    {host, "db.test.com"},
    {user, "dbuser"},
    {password, "secret"},
    {database, "test"},
    {charset, utf_general_ci},
    {auto_commit, off}
  ],
  bank:start_pool(my_pool, 10, ConnectParams).

There would also be a chance to support meaningful defaults per bank driver. I.e. for bank_mysql there could be a default for the port number.

What are your thoughts?

'matthias'.

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.