小伙伴们有没有觉得学习Golang很有意思?有意思就对了!今天就给大家带来《无法连接到包含哈希符号的路径的 FirebirdSQL 数据库》,以下内容将会涉及到,若是在学习中对其中部分知识点有疑问,或许看了本文就能帮到你!
我正在尝试使用 go (v1.14) 中的 firebirdsql 连接到 firebird 数据库。
db_path := "d:\\dbs\\test.fdb"
conn, err := sql.open("firebirdsql", ("sysdba:[email protected]:3050/" + db_path) )
err = conn.ping()
if err != nil {
fmt.println("db.ping failed:", err)
}
上面的代码工作得很好,但是一旦我在路径中引入哈希符号(#)(例如:db_path := "d:\\#dbs\\test.fdb"),我就无法连接并且firebirdsql 抱怨路径无效(它读取直到井号的路径):
db.Ping failed: I/O error during "CreateFile (open)" operation for file "D:\" Error while trying to open file The system cannot find the path specified.
这是firebirdsql中的错误还是我在这里做错了什么?
解决方案
基于Arioch 'The的评论:
将哈希符号替换为 %23 - How to escape hash character in URL。您还可以抽象(对用户隐藏并保留灵活性)特定路径并传递标识符,请参阅 alaliases.conf(Firebird 2.5 及更早版本)或 databases.conf (Firebird 3.0 及更高版本)。
理论要掌握,实操不能落!以上关于《无法连接到包含哈希符号的路径的 FirebirdSQL 数据库》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!
本文内容来源于互联网,如有侵权请联系删除。
