Am 18.01.2014 16:11, schrieb Anton Alexeev:
I'm trying to understand how to use mysql-native driver.
I have a database named "gksu" and a table named "news", the third column has the type "text".
writeln()
just outputs an array of some numbers. How can I convert them to the normal text/string?Here is a part of my code:
auto mdb = new MysqlDB("localhost", "gksu", "pass", "gksu"); auto c = mdb.lockConnection(); scope(exit){ c.close(); } try { c.selectDB("gksu"); auto com = Command(c); com.sql = "SELECT * FROM news LIMIT 0, 30"; ResultSet rs = com.execSQLResult(); writeln(rs[0][2].toString()); } catch(Exception x) { writeln("Execption: ", x.msg); }
Sorry, I can't help with the direct question right now, because,
ironically, I haven't used the mysql driver myself (I would actually
rather like to pass the repository ownership to one of the maintainers).
Just a little comment about the snippet above - the scope(exit)
isn't
necessary because c
is already using RAII to free up the connection
for later reuse. Explicitly calling close
will open a new connection
for each command that is sent to the server.
If nobody else can answer this quickly in the mean time, I'll have a
look at the source later to see what goes wrong.