diff options
author | KeMeGe <chaoskmg@gmail.com> | 2015-03-16 13:53:38 +0800 |
---|---|---|
committer | KeMeGe <chaoskmg@gmail.com> | 2015-03-16 13:53:38 +0800 |
commit | 171d51a08c62b069edf389d4e7ead097dd3dfb32 (patch) | |
tree | caa7dec6d0be4492dcb219a7463147505a90a010 /lib/impure/db_mysql.nim | |
parent | ca8102b96d086bcf95d8859eafe4021f334b5542 (diff) | |
download | Nim-171d51a08c62b069edf389d4e7ead097dd3dfb32.tar.gz |
move database encoding options to setEncoding(), leave open() as it is
Diffstat (limited to 'lib/impure/db_mysql.nim')
-rw-r--r-- | lib/impure/db_mysql.nim | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index cd2be2ff9..b8180cd87 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -212,8 +212,8 @@ proc close*(db: TDbConn) {.tags: [FDb].} = ## closes the database connection. if db != nil: mysql.close(db) -proc open*(connection, user, password, database: string, - charset: string = "utf8"): TDbConn {.tags: [FDb].} = +proc open*(connection, user, password, database: string): TDbConn {. + tags: [FDb].} = ## opens a database connection. Raises `EDb` if the connection could not ## be established. result = mysql.init(nil) @@ -229,7 +229,9 @@ proc open*(connection, user, password, database: string, var errmsg = $mysql.error(result) db_mysql.close(result) dbError(errmsg) - if mysql.set_character_set(result, charset) == 0: - 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 \ No newline at end of file |