Hunt database
Andre Pany
andre at s-e-a-p.de
Tue Nov 3 22:22:30 UTC 2020
On Tuesday, 3 November 2020 at 18:48:16 UTC, Vino wrote:
> On Tuesday, 3 November 2020 at 18:14:33 UTC, Andre Pany wrote:
>> [...]
>
> Hi Andre,
>
> We have also tried to change the connection (con) as
> dbconnect (con) as below, as per the example provided in the
> link https://code.dlang.org/packages/hunt-database, we dont see
> the prepare method needs SqlConnection as first argument and a
> string as second where as we can see the need from the source
> code, so is the example provide in the link is wrong? if yes
> can you please provide an example nor point me to the correct
> documentation link
>
> "Statement stmt = db.prepare("SELECT * FROM user where username
> = :username and age = :age LIMIT 10");"
>
> File : GetConnections.d
> #######################
> module common.GetConnections;
> import hunt.database;
>
> class dbconnect
> {
> public Database con;
> this() { con = new
> Database("mysql://username:password@localhost:3910/testdb"); }
> }
>
> ###################################################################################
> File: GetConfig.d
> #######################
> import common.GetConnections;
> import hunt.database;
>
> auto getConfig(int Seq)
> {
> auto mdb = new dbconnect();
> Statement stmt = mdb.con.prepare("SELECT * FROM settings WHERE
> Seq = :Sq");
> stmt.setParameter("Sq", Seq);
> stmt.execute();
> RowSet rs = stmt.query();
> mdb.conn.close();
> return rs;
> }
> ##################################################################################
> File : app.d
> #######################
> import std.stdio;
> imoprt common.GetConfig;
>
> void main() {
> writeln(getConfig(1));
> }
Please see here
https://www.github.com/huntlabs/hunt-database/tree/master/source%2Fhunt%2Fdatabase%2FDatabase.d
The prepare method of class Database has 2 arguments.
You might create a github issue on the hunt repository and ask
them to update the readme.md.
(So far, I only used arsd-official for database access. Sqlite
was working fine and it also has support for mysql I assume)
Kind regards
Andre
More information about the Digitalmars-d-learn
mailing list