On Sunday, 31 January 2016 at 09:15:04 UTC, Suliman wrote:
I hope that here I will get answer faster then on https://github.com/buggins/ddbc/issues/18

I am using ddbc diver for access to mysql. I need to return result of request to struct. My code is next:

import std.stdio;
import ddbc.all;
import std.stdio;
import std.conv;

void main()
{
        string[string] params;
        MySQLDriver driver = new MySQLDriver();
string url = MySQLDriver.generateUrl("localhost", 3306, "test");
    params = MySQLDriver.setUserAndPassword("root", "pass");
DataSource ds = new ConnectionPoolDataSourceImpl(driver, url, params);

        // creating Connection
        auto conn = ds.getConnection();
        scope(exit) conn.close();

        // creating Statement
        auto stmt = conn.createStatement();
        scope(exit) stmt.close();
        
        string sql = "select * from test.imgs";
        auto images = stmt.executeQuery(sql);
        
        struct myData
        {
         int id;
         string date;
        }
        
        foreach(ref e; stmt.select!myData)
        {
        
        }
        
        /* this code is work
        while(images.next())
        {
                string mydata = images.getString(4);
                writeln(mydata);
                readln;
        }
        */
        
}

I am getting error: Error: no property 'select' for type 'ddbc.core.Statement'

What I am doing wrong?

You forgot to add "import ddbc.pods;"
Sorry for late answer :)
Closing issue.


Reply via email to