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 Home · LibPQ.jl 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!