Re: db_mysql return column name as well?
I would like to use [MonetDB](https://www.monetdb.org) in production as our use case is heavily depending on mysql / mariadb just because it's MyISAM tables are so fast. PostgreSQL and a lot of other DBs I tried faint already on importing the data and are magnitudes slower in querying them. But I agree that for "normal" usage PostgreSQL now became an option. The PostgreSQL of the past was very disappointing though :)
Re: db_mysql return column name as well?
Will I get in trouble for saying: **_MySQL sucks, use PostgreSQL_** :P
Re: db_mysql return column name as well?
Well, the fields of the table are not the same as the fields of the result of a query! AFAIK the "higher level" wrapper can't do what you want. I once played around with it and wrote something like this: import strutils, os # NOTE: Some versions of the nim library have the wrong size for TFIELDS import mysql template mRaise(m: string) = var e = new IOError e.msg = m raise e template mRaise(con: PMySQL) = var e = new IOError e.msg = $ mysql.error(con) raise e template traceIt(m: string, doit: stmt): stmt = echo "Trace: ", m doit proc showFields*(res: PRES) = let fnum = int(mysql.numFields(res)) # cast string to int #var fnames: seq[string] #newSeq(fnames, fnum) for i in 0..
Re: db_mysql return column name as well?
`instantRows` iterator calls `setColumnInfo()` so (untested code :) ) where `theDb` is your dbConn object and `myTestTbl` is the table being queried, and using count(*) to return only one result so that the column representation is not printed for multiple rows var dbC: DbColumns for x in theDb.instantRows(dbC, sql"select count(*) from myTestTbl"): for c in dbC: echo repr(c) and FYI (from db_common lib) DbColumn* = object ## information about a database column name*: string ## name of the column tableName*: string ## name of the table the column belongs to (optional) typ*: DbType ## type of the column primaryKey*: bool ## is this a primary key? foreignKey*: bool ## is this a foreign key? DbColumns* = seq[DbColumn]