www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - mysql-native v2.1.0-rc1: New features

reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
An all-D MySQL/MariaDB client library:
https://github.com/mysql-d/mysql-native
==========================================

Tagged 'v2.1.0-rc1', release candidate for v2.1.0, which mainly adds a 
few new features, inlcuding greatly simplified shortcut syntax for 
prepared statements (with automatic, implicit caching and re-use):

---
int i = 5;
string s = "Hello world";
conn.exec("INSERT INTO table_name VALUES (?, ?)", i, s);
conn.query("SELECT * FROM table_name WHERE id=? AND name=?", i, s);

// Also works:
Prepared stmt = conn.prepare("INSERT ...blah... (?, ?)");
conn.exec(stmt, i, s);
---

As well as additional tools for optional micro-management of 
registering/releasing prepared statements.

Full changelog for this release is in the 'v2.1.x' branch:
https://github.com/mysql-d/mysql-native/blob/v2.1.x/CHANGELOG.md

Final v2.1.0 release is tentatively scheduled for one week from today.
Feb 23
next sibling parent aberba <karabutaworld gmail.com> writes:
On Friday, 23 February 2018 at 22:15:37 UTC, Nick Sabalausky 
(Abscissa) wrote:
 An all-D MySQL/MariaDB client library:
 https://github.com/mysql-d/mysql-native
 ==========================================

 [...]
That's a very useful feature. Will simplify some code.
 As well as additional tools for optional micro-management of 
 registering/releasing prepared statements.

 [...]
Feb 23
prev sibling next sibling parent "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
Minor second release candidate, 'v2.1.0-rc2'. Only thing this changes is 
to update the example in the readme to include the new simplified 
prepared statement interface.
Feb 24
prev sibling next sibling parent reply Suliman <evermind live.ru> writes:
What about string interpolation like:

conn.exec("INSERT INTO table_name VALUES ({i}, {s})"); ?

Instead of:
conn.exec("INSERT INTO table_name VALUES (?, ?)", i, s);
Feb 24
parent reply "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
On 02/25/2018 02:01 AM, Suliman wrote:
 What about string interpolation like:
 
 conn.exec("INSERT INTO table_name VALUES ({i}, {s})"); ?
 
 Instead of:
 conn.exec("INSERT INTO table_name VALUES (?, ?)", i, s);
The syntax is purely, 100% server-side. Mysql-native just passes the whole string, question marks and all, straight off to the server. So whatever syntax the server supports, mysql-native supports. Whatever the server doesn't, mysql-native doesn't. I've heard about a MySQL (I think) syntax like this: "INSERT INTO table_name VALUES (:i, :s)" But I haven't given it a try, and I don't know about its compatability.
Feb 24
parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 2/25/18 2:59 AM, Nick Sabalausky (Abscissa) wrote:
 On 02/25/2018 02:01 AM, Suliman wrote:
 What about string interpolation like:

 conn.exec("INSERT INTO table_name VALUES ({i}, {s})"); ?

 Instead of:
 conn.exec("INSERT INTO table_name VALUES (?, ?)", i, s);
The syntax is purely, 100% server-side. Mysql-native just passes the whole string, question marks and all, straight off to the server. So whatever syntax the server supports, mysql-native supports. Whatever the server doesn't, mysql-native doesn't. I've heard about a MySQL (I think) syntax like this: "INSERT INTO table_name VALUES (:i, :s)" But I haven't given it a try, and I don't know about its compatability.
I've been thinking about something more like this: conn.exec("INSERT INTO table_name VALUES (", i, s, ")"); What I like about this, is that a real SQL insert can have lots of fields. Getting them all straight can be a pain in the ass, especially if you are inserting a couple somewhere. But if the SQL library rearranges this for us, so we can put the data where it should be, it would be much nicer. The one wrinkle that makes this difficult is strings that should be parameters. Are they parameters or SQL statement? I suppose you could wrap the statement strings into something, or the string values into something. String interpolation would be really useful here. e.g.: https://forum.dlang.org/post/odb9hk$2jqm$1 digitalmars.com -Steve
Feb 25
prev sibling parent "Nick Sabalausky (Abscissa)" <SeeWebsiteToContactMe semitwist.com> writes:
Third release candidate, `v2.1.0-rc3`: Snuck in a long-overdue fix for 
#28: "MYXProtocol thrown when using large integers as prepared parameters."

https://github.com/mysql-d/mysql-native/issues/28

-------------------------------

In other news, there will likely be another release immediately after 
v2.1.0 (Though I'll probably skip the release-candidate period on that 
one). Current progress on the follow-up to v2.1.0:

https://github.com/mysql-d/mysql-native/milestone/4?closed=1
Feb 25