File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,9 @@ LibPQ.load!(
75
75
execute (conn, " COMMIT;" )
76
76
```
77
77
78
- ### ` COPY `
78
+ ### ` COPY FROM `
79
79
80
- An alternative to repeated ` INSERT ` queries is the PostgreSQL ` COPY ` query.
80
+ An alternative to repeated ` INSERT ` queries is the PostgreSQL ` COPY FROM ` query.
81
81
` LibPQ.CopyIn ` makes it easier to stream data to the server using a ` COPY FROM STDIN ` query.
82
82
83
83
``` julia
@@ -99,3 +99,23 @@ execute(conn, copyin)
99
99
100
100
close (conn)
101
101
```
102
+
103
+ ### ` COPY TO `
104
+
105
+ An alternative to selection for large datasets in ` SELECT ` queries is the PostgreSQL ` COPY TO ` query.
106
+ ` LibPQ.CopyOut! ` makes it easier to stream data out of the server using a ` COPY TO STDIN ` query.
107
+
108
+ ``` julia
109
+ using LibPQ, CSV, DataFrames
110
+
111
+ conn = LibPQ. Connection (" dbname=postgres user=$DATABASE_USER " )
112
+
113
+ databuf = IOBuffer ()
114
+ copyout = LibPQ. CopyOut! (databuf, " COPY (SELECT * FROM libpqjl_test) TO STDOUT (FORMAT CSV, HEADER);" )
115
+
116
+ execute (conn, copyout)
117
+
118
+ df = DataFrame (CSV. File (databuf))
119
+
120
+ close (conn)
121
+ ```
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ LibPQ.load!
43
43
``` @docs
44
44
LibPQ.CopyIn
45
45
execute(::LibPQ.Connection, ::LibPQ.CopyIn)
46
+ LibPQ.CopyOut!
47
+ execute(::LibPQ.Connection, ::LibPQ.CopyOut!)
46
48
```
47
49
48
50
### Asynchronous
You can’t perform that action at this time.
0 commit comments