extend / bank_mysql Goto Github PK
View Code? Open in Web Editor NEWMySQL driver for Bank.
License: ISC License
MySQL driver for Bank.
License: ISC License
Hi,
I think, renaming sql_query/2 to query/2 wasn't such a good idea, as the atom 'query' is a reserved word in Erlang.
http://erlang.org/doc/reference_manual/introduction.html#id69675
'matthias'.
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'.
Hi!
Please consider getting rid of the compiler warnings. So the project compiles, even if you are pedantic and paranoid like me, when compiling everything with option warnings_as_errors set.
Here's a suggestion:
https://github.com/pannonia-technologies/bank_mysql/commit/4c8c11a3b18e1ee45a1521fb1e99474f67d9f335
'matthias'.
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'.
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'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.