Hello, new to Julia, so please excuse my ignorance. Probably I should be able to figure out how to use LibPQ from the rest of the documentation, but I cannot even get the verbatim example (save for unique database connection information) of a data insertion to work.
Working with Julia 1.0.0 under Atom (Junolab) on a Windows 2012 R2 server.
So this example taken from https://invenia.github.io/LibPQ.jl/stable/index.html fails:
using LibPQ, DataStreams
conn = LibPQ.Connection(βdbname=postgres user=postgres password=XXXXXXXXXXXXβ)
result = execute(conn, ββ"
CREATE TEMPORARY TABLE libpqjl_test (
no_nulls varchar(10) PRIMARY KEY,
yes_nulls varchar(10)
);
ββ")
Data.stream!(
data,
LibPQ.Statement,
conn,
βINSERT INTO libpqjl_test (no_nulls, yes_nulls) VALUES ($1, $2);β,
)
close(conn)
with what seems an obvious error:
Press Enter to start Julia.
Starting Juliaβ¦
_
_ _ ()_ | Documentation: https://docs.julialang.org
() | () () |
_ _ | | __ _ | Type β?β for help, β]?β for Pkg help.
| | | | | | |/ ` | |
| | || | | | (| | | Version 1.0.0 (2018-08-08)
/ |_β|||_β_| | Official https://julialang.org/ release
|__/ |
[info | LibPQ]: CREATE TABLE
ERROR: LoadError: UndefVarError: data not defined
Stacktrace:
[1] top-level scope at none:0
[2] include_string(::Module, ::String, ::String) at .\loading.jl:1002
[3] (::getfield(Atom, Symbol("##118#123")){String,String,Module})() at C:\Users\jort.julia\packages\Atom\WSz3k\src\eval.jl:120
[4] withpath(::getfield(Atom, Symbol("##118#123")){String,String,Module}, ::String) at C:\Users\jort.julia\packages\CodeTools\hB4Hy\src\utils.jl:30
[5] withpath at C:\Users\jort.julia\packages\Atom\WSz3k\src\eval.jl:46 [inlined]
[6] #117 at C:\Users\jort.julia\packages\Atom\WSz3k\src\eval.jl:117 [inlined]
[7] hideprompt(::getfield(Atom, Symbol("##117#122")){String,String,Module}) at C:\Users\jort.julia\packages\Atom\WSz3k\src\repl.jl:76
[8] macro expansion at C:\Users\jort.julia\packages\Atom\WSz3k\src\eval.jl:116 [inlined]
[9] (::getfield(Atom, Symbol("##116#121")){Dict{String,Any}})() at .\task.jl:85
in expression starting at H:\Julia_Projects\ODM\libpq_test.jl:12
since βdataβ is not defined anywhere. How should it be defined so that it works with the parameters in the INSERT statement? Iβve been unable to find a clear example of LibPQ usage anywhere.
Many thanks!