Merge pull request #2337 from kemege/db_charset

Add character set options when opening DB connection, default to UTF-8
This commit is contained in:
Andreas Rumpf
2015-03-17 01:32:26 +01:00
committed by ringabout
parent 0a735a6f12
commit e745c73dea

View File

@@ -229,3 +229,9 @@ proc open*(connection, user, password, database: string): TDbConn {.
var errmsg = $mysql.error(result)
db_mysql.close(result)
dbError(errmsg)
proc setEncoding*(connection: TDbConn, encoding: string): bool {.
tags: [FDb].} =
## sets the encoding of a database connection, returns true for
## success, false for failure.
result = mysql.set_character_set(connection, encoding) == 0