@@ -16,36 +16,36 @@ for example:
1616package main
1717
1818import (
19- " context"
20- " database/sql"
21- " log"
19+ " context"
20+ " database/sql"
21+ " log"
2222
23- _ " github.com/mashiike/redshift-data-sql-driver"
23+ _ " github.com/mashiike/redshift-data-sql-driver"
2424)
2525
2626func main () {
27- db , err := sql.Open (" redshift-data" , " workgroup(default)/dev?timeout=1m" )
28- if err != nil {
29- log.Fatalln (err)
30- }
31- defer db.Close ()
32- rows , err := db.QueryContext (
33- context.Background (),
34- ` SELECT table_schema,table_name,table_type FROM svv_tables WHERE table_schema not like :ignore_schema` ,
35- sql.Named (" ignore_schema" , " pg_% " ),
36- )
37- if err != nil {
38- log.Fatalln (err)
39- }
40- for rows.Next () {
41- var schema , name , tableType string
42- err := rows.Scan (&schema, &name, &tableType)
43- if err != nil {
44- log.Println (err)
45- return
46- }
47- log.Printf (" %s .%s \t %s " , schema, name, tableType)
48- }
27+ db , err := sql.Open (" redshift-data" , " workgroup(default)/dev?timeout=1m" )
28+ if err != nil {
29+ log.Fatalln (err)
30+ }
31+ defer db.Close ()
32+ rows , err := db.QueryContext (
33+ context.Background (),
34+ ` SELECT table_schema,table_name,table_type FROM svv_tables WHERE table_schema not like :ignore_schema` ,
35+ sql.Named (" ignore_schema" , " pg_% " ),
36+ )
37+ if err != nil {
38+ log.Fatalln (err)
39+ }
40+ for rows.Next () {
41+ var schema , name , tableType string
42+ err := rows.Scan (&schema, &name, &tableType)
43+ if err != nil {
44+ log.Println (err)
45+ return
46+ }
47+ log.Printf (" %s .%s \t %s " , schema, name, tableType)
48+ }
4949}
5050```
5151
@@ -65,14 +65,46 @@ Parameter settings are in the format of URL query parameter
6565
6666` workgroup(default)/dev?timeout=1m&polling=1ms `
6767
68- ## Unsupported Features
68+ ### Transaction Notes
6969
70- The following functions are not available
70+ The Redshift Data API does not have an interface for pasting transactions and querying sequentially.
71+ Therefore, we have implemented an unusual implementation.
7172
72- ### [ BeginTx] ( https://pkg.go.dev/database/sql#DB.BeginTx ) ,[ Begin] ( https://pkg.go.dev/database/sql#DB.Begin )
7373
74- The Redshift Data API does not have an interface for pasting transactions and querying sequentially.
75- Therefore, transactional functionality is not available.
74+ ``` go
75+ package main
76+
77+ import (
78+ " context"
79+ " database/sql"
80+ " log"
81+
82+ _ " github.com/mashiike/redshift-data-sql-driver"
83+ )
84+
85+ func main () {
86+ db , err := sql.Open (" redshift-data" , " workgroup(default)/dev?timeout=1m" )
87+ if err != nil {
88+ log.Fatalln (err)
89+ }
90+ defer db.Close ()
91+ tx , err := db.BeginTx (context.Background (), nil )
92+ if err != nil {
93+ log.Fatalln (err)
94+ }
95+ tx.ExecContext (context.Background (), " INSERT INTO foo VALUES (1)" )
96+ tx.ExecContext (context.Background (), " INSERT INTO foo VALUES (2)" )
97+ tx.ExecContext (context.Background (), " INSERT INTO foo VALUES (3)" )
98+ tx.Commit () // BatchExecuteStatement API is called here, and the queries called during the transaction are executed together
99+ }
100+ ```
101+
102+ Also, because the interface does not match, ` Query ` and ` QueryContext ` in the transaction are not supported.
103+ ` Exec ` and ` ExecContext ` in the transaction are not supported.
104+
105+ ## Unsupported Features
106+
107+ The following functions are not available
76108
77109### [ Prepare] ( https://pkg.go.dev/database/sql#DB.Prepare )
78110
0 commit comments