digitalmars.D.learn - Hunt database
- Vino (49/49) Nov 03 2020 Hi All,
- Imperatorn (2/6) Nov 03 2020 What datatype is Seq in your settings table?
- Vino (3/11) Nov 03 2020 Hi,
- Andre Pany (9/58) Nov 03 2020 The hunt database class has a prepare method which expects a
- Vino (46/113) Nov 03 2020 Hi Andre,
- Andre Pany (10/57) Nov 03 2020 Please see here
Hi All, Currently testing Hunt database, and facing an issue as below, hence request your help File : GetConnections.d module common.GetConnections; import hunt.database; class Connections { public Database conn; this() { conn = new Database("mysql://username:password localhost:3910/testdb"); } } File: GetConfig.d import common.GetConnections; import hunt.database; auto getConfig(int Seq) { auto mdb = new Connections(); Statement stmt = mdb.conn.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)); } Error: GetConfig.d Error: function hunt.database.Database.Database.prepare(SqlConnection conn, string sql) is not callable using argument types (string) cannot pass argument "SELECT * FROM settings WHERE Seq = :Sq" of type string to parameter SqlConnection conn Error: template hunt.database.Statement.Statement.setParameter cannot deduce function from argument types !()(int, int), candidates are: From, Vino.B
Nov 03 2020
On Tuesday, 3 November 2020 at 14:05:18 UTC, Vino wrote:Hi All, Currently testing Hunt database, and facing an issue as below, hence request your help [...]What datatype is Seq in your settings table?
Nov 03 2020
On Tuesday, 3 November 2020 at 14:47:01 UTC, Imperatorn wrote:On Tuesday, 3 November 2020 at 14:05:18 UTC, Vino wrote:Hi, The filed Seq is int.Hi All, Currently testing Hunt database, and facing an issue as below, hence request your help [...]What datatype is Seq in your settings table?
Nov 03 2020
On Tuesday, 3 November 2020 at 14:05:18 UTC, Vino wrote:Hi All, Currently testing Hunt database, and facing an issue as below, hence request your help File : GetConnections.d module common.GetConnections; import hunt.database; class Connections { public Database conn; this() { conn = new Database("mysql://username:password localhost:3910/testdb"); } } File: GetConfig.d import common.GetConnections; import hunt.database; auto getConfig(int Seq) { auto mdb = new Connections(); Statement stmt = mdb.conn.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)); } Error: GetConfig.d Error: function hunt.database.Database.Database.prepare(SqlConnection conn, string sql) is not callable using argument types (string) cannot pass argument "SELECT * FROM settings WHERE Seq = :Sq" of type string to parameter SqlConnection conn Error: template hunt.database.Statement.Statement.setParameter cannot deduce function from argument types !()(int, int), candidates are: From, Vino.BThe hunt database class has a prepare method which expects a SqlConnection as first argument and a string as second argument. You are passing only a string, therefore the first error. Ad you name your database instance also connection (conn) and your Connections class database (mdb) it makes the source code quite hard to understand :) Kind regards Andre
Nov 03 2020
On Tuesday, 3 November 2020 at 18:14:33 UTC, Andre Pany wrote:On Tuesday, 3 November 2020 at 14:05:18 UTC, Vino 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)); }Hi All, Currently testing Hunt database, and facing an issue as below, hence request your help File : GetConnections.d module common.GetConnections; import hunt.database; class Connections { public Database conn; this() { conn = new Database("mysql://username:password localhost:3910/testdb"); } } File: GetConfig.d import common.GetConnections; import hunt.database; auto getConfig(int Seq) { auto mdb = new Connections(); Statement stmt = mdb.conn.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)); } Error: GetConfig.d Error: function hunt.database.Database.Database.prepare(SqlConnection conn, string sql) is not callable using argument types (string) cannot pass argument "SELECT * FROM settings WHERE Seq = :Sq" of type string to parameter SqlConnection conn Error: template hunt.database.Statement.Statement.setParameter cannot deduce function from argument types !()(int, int), candidates are: From, Vino.BThe hunt database class has a prepare method which expects a SqlConnection as first argument and a string as second argument. You are passing only a string, therefore the first error. Ad you name your database instance also connection (conn) and your Connections class database (mdb) it makes the source code quite hard to understand :) Kind regards Andre
Nov 03 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: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[...]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)); }
Nov 03 2020