[xorm.NewEngine] I gave wrong 'dataSourceName' but can't panic the error #1424

Closed
opened 2019-09-17 09:29:59 +00:00 by conero · 2 comments
conero commented 2019-09-17 09:29:59 +00:00 (Migrated from github.com)

I used xorm to connect Mysql.

// code ....
engine, err := xorm.NewEngine(vtype, dsn)
// dsn is wrong
// but never panic the error 

// I had to check use a SQL like:
md, er := engine.QueryString("select database() as `cdb`, user() as `user`")
// er =>
// `Error 1045: Access denied for user 'root'@'localhost' (using password: YES)`

// code ....

What I gonna to, please give me a hand.

I used xorm to connect *Mysql*. ```go // code .... engine, err := xorm.NewEngine(vtype, dsn) // dsn is wrong // but never panic the error // I had to check use a SQL like: md, er := engine.QueryString("select database() as `cdb`, user() as `user`") // er => // `Error 1045: Access denied for user 'root'@'localhost' (using password: YES)` // code .... ``` *What I gonna to, please give me a hand.*

You could use engine.Ping to test if the database is alive.

You could use `engine.Ping` to test if the database is alive.
conero commented 2019-09-17 14:35:52 +00:00 (Migrated from github.com)

@lunny Thanks for your help. But I think engine.Ping isn't direct for the purpose, maybe like IsVaild or Error better. It's a litter proposal for.

@lunny Thanks for your help. But I think `engine.Ping` isn't direct for the purpose, maybe like `IsVaild` or `Error` better. It's a litter proposal for.
lunny added the
wontfix
label 2020-02-29 09:30:07 +00:00
lunny closed this issue 2020-02-29 09:30:13 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1424
No description provided.