Re: Hunt database
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
Re: Does dmd's -i "include imported modules in the compilation" switch generate object files?
On Tue, Nov 03, 2020 at 10:42:55AM -0800, Ali Çehreli via Digitalmars-d-learn wrote: > -i is a useful feature: > > https://dlang.org/dmd-linux.html > > Does dmd compile auto-included files separately? Does it generate > temporary object files? If so, where does it write the files? Would -i > cause race conditions on the file system? [...] I believe -i behaves as though you manually typed the names of the source files on the command line. So it would do what the compiler would usually do in the latter case. AFAIK, that means it loads everything into memory and produces only a single object file for the final executable. Separate compilation only happens if you invoke the compiler separately for each source file or group of source files. T -- We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true. -- Robert Wilensk
Re: Hunt database
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 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 The 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 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)); }
Does dmd's -i "include imported modules in the compilation" switch generate object files?
-i is a useful feature: https://dlang.org/dmd-linux.html Does dmd compile auto-included files separately? Does it generate temporary object files? If so, where does it write the files? Would -i cause race conditions on the file system? Thank you, Ali
Re: Hunt database
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.B The 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
Re: Hunt database
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?
Re: Hunt database
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 All, Currently testing Hunt database, and facing an issue as below, hence request your help [...] What datatype is Seq in your settings table? Hi, The filed Seq is int.
Hunt database
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