nakagami / firebirdsql

Firebird RDBMS sql driver for Go (golang)
MIT License
220 stars 60 forks source link

Firebird 2.1 on Windows #153

Open sashanv opened 11 months ago

sashanv commented 11 months ago

We are using Firebird 2.1. Tell me how to read data from it on Go? Through your driver, it turns out to connect to the database and that's it, all requests come back with basically empty answers, although there is data in the database.

nakagami commented 11 months ago

I don't have an environment where Firebird 2.1 works, so I can't try it. Maybe Firebird 2.1 does not work.

If the database with a character set other than utf-8, please set the charset parameter. https://github.com/nakagami/firebirdsql#optional

hjlp20150803 commented 10 months ago

I don't have an environment where Firebird 2.1 works, so I can't try it. Maybe Firebird 2.1 does not work.

If the database with a character set other than utf-8, please set the charset parameter. https://github.com/nakagami/firebirdsql#optional

I got same result,here is my code: package main

import ( "database/sql" "fmt"

_ "github.com/nakagami/firebirdsql"

)

func main() { var n int conn, er := sql.Open("firebirdsql", "SYSDBA:masterkey@localhost:f:\monkey.fdb?charset=utf8") if er != nil { fmt.Println("open failed:", er) return } defer conn.Close() conn.QueryRow("SELECT Count(*) FROM rdb$relations").Scan(&n) fmt.Println("Relations count=", n)

}

go run simple.go Relations count= 0

firebirddb 2.5.9,and isql tool: SQL> create database "f:\monkey.fdb" page_size 8192 user 'SYSDBA' password 'masterkey'; Server version: WI-V2.5.9.27139 Firebird 2.5 WI-V2.5.9.27139 Firebird 2.5/XNet (LENOVO)/P12 WI-V2.5.9.27139 Firebird 2.5/XNet (LENOVO)/P12 SQL> SELECT RDB$RELATION_ID FROM RDB$DATABASE;

RDB$RELATION_ID

        128

could you take a look what's wrong, and could you provide a sample for windows?

nakagami commented 10 months ago

thanks,

\ is escape char, and / can also be used as a path separator in windows.

Probably, the connection string should be as follows

SYSDBA:masterkey@localhost:f:\\monkey.fdb?charset=utf8

or

SYSDBA:masterkey@localhost:f:/monkey.fdb?charset=utf8
hjlp20150803 commented 10 months ago

SYSDBA:masterkey@localhost:f:/monkey.fdb?charset=utf8

conn, er := sql.Open("firebirdsql", "SYSDBA:masterkey@localhost:f:/monkey.fdb?charset=utf8"),

this still not work, acturally "SYSDBA:masterkey@localhost:f:\monkey.fdb?charset=utf8" is what I used,but it show is "SYSDBA:masterkey@localhost:f:\monkey.fdb?charset=utf8", only one "\", I don't know why.

thanks for your reply, if you could install firebirdsql2.59, or higher version on your windows platform, and test it, then maybe better, support a platform is big deal.

hjlp20150803 commented 10 months ago

I used double "\\",but it always shows single "\"

nakagami commented 10 months ago

Oh, sorry.

Try to follow the pattern of connection strings found at https://github.com/nakagami/firebirdsql/blob/master/utils_test.go#L41-L49

for example

SYSDBA:masterkey@localhost/f:\\monkey.fdb?charset=utf8

or

SYSDBA:masterkey@localhost/f:/monkey.fdb?charset=utf8
hjlp20150803 commented 10 months ago

SYSDBA:masterkey@localhost/f:\monkey.fdb?charset=utf8

thanks a lot,it works

hjlp20150803 commented 10 months ago

this works: "SYSDBA:masterkey@localhost/f:\monkey.fdb?charset=utf8" this not works: SYSDBA:masterkey@localhost/f:/monkey.fdb?charset=utf8

nakagami commented 10 months ago

thanks I didn't know how it works in windows, so I learned a lot.

hjlp20150803 commented 10 months ago

thanks I didn't know how it works in windows, so I learned a lot.

one more thing, I test firebird 3.0, it does not work:

SQL> create database "f:\rain.fdb" page_size 8192 user 'SYSDBA' password 'masterkey'; Server version: WI-V3.0.11.33703 Firebird 3.0 SQL> SELECT RDB$RELATION_ID FROM RDB$DATABASE;

RDB$RELATION_ID

        128

===================================== package main

import ( "database/sql" "fmt"

_ "github.com/nakagami/firebirdsql"

)

func main() { var n int conn, er := sql.Open("firebirdsql", "SYSDBA:masterkey@localhost/:f:\rain.fdb") if er != nil { fmt.Println("open failed:", er) return } defer conn.Close()

conn.QueryRow("SELECT RDB$RELATION_ID FROM RDB$DATABASE").Scan(&n)

fmt.Println("Relations count=", n)

}

./simple Relations count= 0

hjlp20150803 commented 10 months ago

"SYSDBA:masterkey@localhost/:f:\rain.fdb","\" is double,not single,so this not wrong

hjlp20150803 commented 10 months ago

thanks I didn't know how it works in windows, so I learned a lot.

I restart the system, and it works for firebird3.0: /firebirdsql/simple$ ./simple.exe Relations count= 128