@@ -2,14 +2,11 @@ package main
2
2
3
3
import (
4
4
"context"
5
+ qdb "github.com/questdb/go-questdb-client/v3"
5
6
"log"
6
7
"time"
7
-
8
- qdb "github.com/questdb/go-questdb-client/v3"
9
8
)
10
9
11
- const dateOnly = "2006-01-02"
12
-
13
10
func main () {
14
11
ctx := context .TODO ()
15
12
sender , err := qdb .NewLineSender (
@@ -33,32 +30,34 @@ func main() {
33
30
}()
34
31
35
32
// Send a few ILP messages.
36
- bday , err := time .Parse (dateOnly , "1856-07-10 " )
33
+ tradedTs , err := time .Parse (time . RFC3339 , "2022-08-06T15:04:05.123456Z " )
37
34
if err != nil {
38
35
log .Fatal (err )
39
36
}
40
37
err = sender .
41
- Table ("inventors_go" ).
42
- Symbol ("born" , "Austrian Empire" ).
43
- TimestampColumn ("birthdate" , bday ). // Epoch in micros.
44
- Int64Column ("id" , 0 ).
45
- StringColumn ("name" , "Nicola Tesla" ).
46
- At (ctx , time .Now ()) // Epoch in nanos.
38
+ Table ("trades_go" ).
39
+ Symbol ("pair" , "USDGBP" ).
40
+ Symbol ("type" , "buy" ).
41
+ Float64Column ("traded_price" , 0.83 ).
42
+ Float64Column ("limit_price" , 0.84 ).
43
+ Int64Column ("qty" , 100 ).
44
+ At (ctx , tradedTs )
47
45
if err != nil {
48
46
log .Fatal (err )
49
47
}
50
48
51
- bday , err = time .Parse (dateOnly , "1847-02-11 " )
49
+ tradedTs , err = time .Parse (time . RFC3339 , "2022-08-06T15:04:06.987654Z " )
52
50
if err != nil {
53
51
log .Fatal (err )
54
52
}
55
53
err = sender .
56
- Table ("inventors_go" ).
57
- Symbol ("born" , "USA" ).
58
- TimestampColumn ("birthdate" , bday ).
59
- Int64Column ("id" , 1 ).
60
- StringColumn ("name" , "Thomas Alva Edison" ).
61
- AtNow (ctx )
54
+ Table ("trades_go" ).
55
+ Symbol ("pair" , "GBPJPY" ).
56
+ Symbol ("type" , "sell" ).
57
+ Float64Column ("traded_price" , 135.97 ).
58
+ Float64Column ("limit_price" , 0.84 ).
59
+ Int64Column ("qty" , 400 ).
60
+ At (ctx , tradedTs )
62
61
if err != nil {
63
62
log .Fatal (err )
64
63
}
0 commit comments