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 @@ -71,9 +71,9 @@ LibPQ.load!(
71
71
execute (conn, " COMMIT;" )
72
72
```
73
73
74
- ### ` COPY `
74
+ ### ` COPY FROM `
75
75
76
- An alternative to repeated ` INSERT ` queries is the PostgreSQL ` COPY ` query.
76
+ An alternative to repeated ` INSERT ` queries is the PostgreSQL ` COPY FROM ` query.
77
77
` LibPQ.CopyIn ` makes it easier to stream data to the server using a ` COPY FROM STDIN ` query.
78
78
79
79
``` julia
@@ -95,3 +95,23 @@ execute(conn, copyin)
95
95
96
96
close (conn)
97
97
```
98
+
99
+ ### ` COPY TO `
100
+
101
+ An alternative to selection for large datasets in ` SELECT ` queries is the PostgreSQL ` COPY TO ` query.
102
+ ` LibPQ.CopyOut! ` makes it easier to stream data out of the server using a ` COPY TO STDIN ` query.
103
+
104
+ ``` julia
105
+ using LibPQ, CSV, DataFrames
106
+
107
+ conn = LibPQ. Connection (" dbname=postgres user=$DATABASE_USER " )
108
+
109
+ databuf = IOBuffer ()
110
+ copyout = LibPQ. CopyOut! (databuf, " COPY (SELECT * FROM libpqjl_test) TO STDOUT (FORMAT CSV, HEADER);" )
111
+
112
+ execute (conn, copyout)
113
+
114
+ df = DataFrame (CSV. File (databuf))
115
+
116
+ close (conn)
117
+ ```
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