digitalmars.D.learn - Mysql-native need some help please
- Lars Johansson (20/20) Jan 17 I'm exploring ways of accessing mysql and are now trying
- bauss (3/23) Jan 17 You need to use .get!T on the variant, instead of casting.
- Lars Johansson (16/34) Jan 18 Thank you it works like a charm.
I'm exploring ways of accessing mysql and are now trying
mysql-native I have the following code:
range = conn.query("Show processlist");
foreach (rad; range){
writeln(rad[6]);
}
}
now I want to test if rad[6] begins with "start", like this:
range = conn.query("Show processlist");
foreach (rad; range){
// string stat = cast (string) rad[6];
if (rad[6].startsWith("start")){
writeln("match");
}
}
whatever I try casting or comparing I'm stuck on errors pointing
out I cannot cast/convert `VariantN!32LU` to string.
I assumed an element range[] should be of type 'string', but it
seems to be of type `VariantN!32LU` whatever that is.
I really need help. I'm stuck.
Jan 17
On Saturday, 17 January 2026 at 16:15:50 UTC, Lars Johansson
wrote:
I'm exploring ways of accessing mysql and are now trying
mysql-native I have the following code:
range = conn.query("Show processlist");
foreach (rad; range){
writeln(rad[6]);
}
}
now I want to test if rad[6] begins with "start", like this:
range = conn.query("Show processlist");
foreach (rad; range){
// string stat = cast (string) rad[6];
if (rad[6].startsWith("start")){
writeln("match");
}
}
whatever I try casting or comparing I'm stuck on errors
pointing out I cannot cast/convert `VariantN!32LU` to string.
I assumed an element range[] should be of type 'string', but it
seems to be of type `VariantN!32LU` whatever that is.
I really need help. I'm stuck.
You need to use .get!T on the variant, instead of casting.
Jan 17
On Saturday, 17 January 2026 at 17:18:41 UTC, bauss wrote:On Saturday, 17 January 2026 at 16:15:50 UTC, Lars Johansson wrote:Thank you it works like a charm. I also found out that .toString works. I should have been able to find toString immediately, but .get!T I probably never have found myself. Can you tell which one is best? And the type `VariantN!32LU` why? It looks very odd to me. I have tried to learn D a couple of times before, but always given up on odd things like `VariantN!32LU`. This time I try a bit harder. I do not learn well by books, courses or videos. I learn by solving a small problem I have and then expand. My intention is to build a compiler or an OS just for fun, or a world class SAP connector. Right now I am too busy with life and $work, the latter will end this year giving me more time for programming. I hope D will work for me. Again thanks for good and fast help.this: range = conn.query("Show processlist"); foreach (rad; range){ // string stat = cast (string) rad[6]; if (rad[6].startsWith("start")){ writeln("match"); } } whatever I try casting or comparing I'm stuck on errors pointing out I cannot cast/convert `VariantN!32LU` to string. I assumed an element range[] should be of type 'string', but it seems to be of type `VariantN!32LU` whatever that is. I really need help. I'm stuck.You need to use .get!T on the variant, instead of casting.
Jan 18








Lars Johansson <lasse 11dim.se>