forked from nakagami/firebirdsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'nakagami:master' into master
- Loading branch information
Showing
38 changed files
with
1,730 additions
and
782 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
matrix: | ||
go: ['1.20', '1.21', '1.22'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup FirebirdSQL container | ||
uses: juarezr/[email protected] | ||
with: | ||
version: '2.5-ss' | ||
isc_password: "masterkey" | ||
|
||
- name: Set up Go ${{ matrix.go }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
matrix: | ||
go: ['1.20', '1.21', '1.22'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Firebird | ||
run: | | ||
sudo apt install firebird3.0-server -y | ||
sudo cp _attic/firebird.conf /etc/firebird/3.0 | ||
sudo systemctl restart firebird3.0 | ||
sudo chmod 0664 /etc/firebird/3.0/SYSDBA.password | ||
grep '=' /etc/firebird/3.0/SYSDBA.password |sed 's/^/export /' >test_user.env | ||
- name: Set up Go ${{ matrix.go }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: | | ||
source test_user.env | ||
go test -v ./... |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# firebirdsql (Go firebird sql driver) | ||
|
||
Firebird RDBMS https://firebirdsql.org SQL driver for Go | ||
|
||
## Requirements | ||
|
||
* Firebird 2.5 or higher | ||
* Golang 1.20 or higher | ||
|
||
## Example | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"database/sql" | ||
_ "github.com/nakagami/firebirdsql" | ||
) | ||
|
||
func main() { | ||
var n int | ||
conn, _ := sql.Open("firebirdsql", "user:password@servername/foo/bar.fdb") | ||
defer conn.Close() | ||
conn.QueryRow("SELECT Count(*) FROM rdb$relations").Scan(&n) | ||
fmt.Println("Relations count=", n) | ||
|
||
} | ||
``` | ||
|
||
|
||
See also driver_test.go | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/nakagami/firebirdsql" | ||
) | ||
|
||
func main() { | ||
dsn := "user:password@servername/foo/bar.fdb" | ||
events := []string{"my_event", "order_created"} | ||
fbEvent, _ := firebirdsql.NewFBEvent(dsn) | ||
defer fbEvent.Close() | ||
sbr, _ := fbEvent.Subscribe(events, func(event firebirdsql.Event) { //or use SubscribeChan | ||
fmt.Printf("event: %s, count: %d, id: %d, remote id:%d \n", event.Name, event.Count, event.ID, event.RemoteID) | ||
}) | ||
defer sbr.Unsubscribe() | ||
go func() { | ||
fbEvent.PostEvent(events[0]) | ||
fbEvent.PostEvent(events[1]) | ||
}() | ||
<- make(chan struct{}) //wait | ||
} | ||
``` | ||
|
||
See also _example | ||
|
||
## Connection string | ||
|
||
```bash | ||
user:password@servername[:port_number]/database_name_or_file[?params1=value1[¶m2=value2]...] | ||
``` | ||
|
||
|
||
### General | ||
|
||
- user: login user | ||
- password: login password | ||
- servername: Firebird server's host name or IP address. | ||
- port_number: Port number. default value is 3050. | ||
- database_name_or_file: Database path (or alias name). | ||
|
||
### Optional | ||
|
||
param1, param2... are | ||
|
||
| Name | Description | Default | Note | | ||
| --- | --- | --- | --- | | ||
| auth_plugin_name | Authentication plugin name. | Srp256 | Srp256/Srp/Legacy_Auth are available. | | ||
| column_name_to_lower | Force column name to lower | false | For "github.com/jmoiron/sqlx" | | ||
| role | Role name | | | | ||
| timezone | Time Zone name | | For Firebird 4.0+ | | ||
| wire_crypt | Enable wire data encryption or not. | true | For Firebird 3.0+ | | ||
| charset | Firebird Charecter Set | | | | ||
|
||
## GORM for Firebird | ||
|
||
See https://github.com/flylink888/gorm-firebird |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// 1. Get copy of Firebird 5 sources or at least src/include from Firebird 5 sources | ||
// 2. Run CGO_CFLAGS=-I/path/to/firebird/src/include go run ./_attic ./errmsgs.go | ||
|
||
//#include "msgs.h" | ||
import "C" | ||
import ( | ||
"strings" | ||
) | ||
|
||
var outFile *os.File | ||
|
||
func writeOut(val string) { | ||
_, err := outFile.WriteString(val) | ||
if err != nil { | ||
fmt.Printf("Unable to write file: %v\n", err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func main() { | ||
var err error | ||
|
||
if len(os.Args) < 2 { | ||
fmt.Println("Output file required") | ||
os.Exit(1) | ||
} | ||
if outFile, err = os.OpenFile(os.Args[1], os.O_CREATE|os.O_RDWR, 0644); err != nil { | ||
fmt.Printf("Unable to open file: %v\n", err) | ||
} | ||
defer outFile.Close() | ||
|
||
writeOut(`/**************************************************************************** | ||
The contents of this file are subject to the Interbase Public | ||
License Version 1.0 (the "License"); you may not use this file | ||
except in compliance with the License. You may obtain a copy | ||
of the License at http://www.Inprise.com/IPL.html | ||
Software distributed under the License is distributed on an | ||
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express | ||
or implied. See the License for the specific language governing | ||
rights and limitations under the License. | ||
*****************************************************************************/ | ||
package firebirdsql | ||
var errmsgs = map[int]string{ | ||
`) | ||
|
||
C.process_messages() | ||
writeOut("}\n") | ||
} | ||
|
||
//export addMessage | ||
func addMessage(code C.int, message *C.char) { | ||
var msg string = C.GoString(message) | ||
if !strings.HasSuffix(msg, `\n"`) { | ||
msg = msg[:len(msg)-1] | ||
msg += `\n"` | ||
} | ||
writeOut(fmt.Sprintf("\t%d: %s,\n", int(code), msg)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RemoteAccess = true | ||
RemoteBindAddress = 0.0.0.0 | ||
|
||
DefaultTimeZone = GMT | ||
AuthServer = Srp256,Srp,Legacy_Auth | ||
WireCrypt = Enabled |
Oops, something went wrong.