'Connection' argument in 'Open' was not used, so MySQL host and port were always default ones. Now 'Connection' is treated as 'host:port'.
This commit is contained in:
parent
52a8226edd
commit
4396270fc7
1 changed files with 9 additions and 3 deletions
|
|
@ -195,8 +195,14 @@ proc Open*(connection, user, password, database: string): TDbConn {.
|
||||||
## be established.
|
## be established.
|
||||||
result = mysql.Init(nil)
|
result = mysql.Init(nil)
|
||||||
if result == nil: dbError("could not open database connection")
|
if result == nil: dbError("could not open database connection")
|
||||||
if mysql.RealConnect(result, "", user, password, database,
|
var
|
||||||
0'i32, nil, 0) == nil:
|
cnctn = connection.split(':')
|
||||||
|
host = cnctn[0]
|
||||||
|
port: int32 = 3306
|
||||||
|
if cnctn.len > 1:
|
||||||
|
port = int32((cnctn[1]).parseInt())
|
||||||
|
if mysql.RealConnect(result, host, user, password, database,
|
||||||
|
port, nil, 0) == nil:
|
||||||
var errmsg = $mysql.error(result)
|
var errmsg = $mysql.error(result)
|
||||||
db_mysql.Close(result)
|
db_mysql.Close(result)
|
||||||
dbError(errmsg)
|
dbError(errmsg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue