Vibe/Mysql Testing

Andre Pany andre at s-e-a-p.de
Thu Oct 17 20:21:39 UTC 2019


On Thursday, 17 October 2019 at 19:05:44 UTC, Vino wrote:
> Hi All,
>
>   Request your help on the below code and error
>
> Error:
> source\app.d(25,15): Error: none of the overloads of writeBody 
> are callable using argument types (VariantN!20LU), candidates 
> are
>
> Code:
> import vibe.vibe;
> import std.array : array;
> import mysql;
> import std.stdio;
> import std.range;
>
> void main()
> {
> 	auto settings = new HTTPServerSettings;
> 	settings.port = 8080;
> 	settings.bindAddresses = ["127.0.0.1"];
> 	listenHTTP(settings, &hello);
>
> 	logInfo("Please open http://127.0.0.1:8080/ in your browser.");
> 	runApplication();
> }
>
> void hello(HTTPServerRequest req, HTTPServerResponse res)
> {
> 	auto connectionStr = 
> "host=test.srv.com;port=3910;user=testusr;pwd=xxxx#;db=test";
> 	Connection conn = new Connection(connectionStr);
> 	scope(exit) conn.close();
> 	ResultRange range = conn.query("SELECT host_name FROM 
> `hosts_coll`");
> 	Row row = range.front;
> 	res.writeBody(row[0]);
> }
>
> From,
> Vino.B

Hi,

I assume you are using this mysql package 
http://code.dlang.org/packages/mysql-native.
(If not please check wheter the package you are using is vibe-d 
compliant.)

The mysql package uses Variant from Phobos for storing values. 
For your example, you could write 
```res.writeBody(row[0].toString());```

Kind regards
Andre



More information about the Digitalmars-d-learn mailing list