www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Vibe/Mysql Testing

reply Vino <akashvino79 gmail.com> writes:
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 = 

	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
Oct 17 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
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 = 

 	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
Oct 17 2019
parent Vino <akashvino79 gmail.com> writes:
On Thursday, 17 October 2019 at 20:21:39 UTC, Andre Pany wrote:
 On Thursday, 17 October 2019 at 19:05:44 UTC, Vino wrote:
 [...]
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
Hi Andre, Thanks it worked. From, Vino.B
Oct 17 2019