Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebird 2.1 on Windows #153

Open
sashanv opened this issue Aug 4, 2023 · 12 comments
Open

Firebird 2.1 on Windows #153

sashanv opened this issue Aug 4, 2023 · 12 comments

Comments

@sashanv
Copy link

sashanv commented Aug 4, 2023

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
Copy link
Owner

nakagami commented Aug 5, 2023

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
Copy link

hjlp20150803 commented Aug 23, 2023

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
Copy link
Owner

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
Copy link

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
Copy link

hjlp20150803 commented Aug 24, 2023

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

@nakagami
Copy link
Owner

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
Copy link

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

thanks a lot,it works

@hjlp20150803
Copy link

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

@nakagami
Copy link
Owner

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

@hjlp20150803
Copy link

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
Copy link

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

@hjlp20150803
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants