For the PostgreSQL package, when I do fetchdf against the result of execute,
instead of the stmt, it does work. Another problem solved!
The DataFrame returned by fetchdf seems to have lost the type information. Am
I understanding that right? It seems like undesirable behavior.
-------------------------------
stmt = prepare(conn, "SELECT isim::int, id::int, x::int, t::double precision,
y::int, regular::int, censor::int, wait::double precision from obs2619 where
isim=1")
result = execute(stmt)
obs = fetchdf(result)
----------------------------
produces
julia> eltypes(obs)
8-element Array{Type{T},1}:
Any
Any
Any
Any
Any
Any
Any
Any
Ross
________________________________
From: [email protected] [[email protected]] on behalf of
Cameron McBride [[email protected]]
Sent: Wednesday, May 04, 2016 3:17 AM
To: julia-users
Subject: Re: [julia-users] Can't add PostgreSQL
I've been using PostgreSQL and DBI just fine for a few months now.
The implementation has a few edges that need polishing and work, but the basics
work just fine for the julia 0.4.x branch.
The problem you ran into with fetchdf() not being implemented is that you tried
to run it on the stmt (before running execute). This is one of the rough edges
that not all convenience functions are implemented. In short, I just confirmed
the following example runs on julia 0.4.5 and the latest DBI.jl / PostgreSQL.jl:
# slightly modified example from https://github.com/JuliaDB/PostgreSQL.jl
using DBI
using PostgreSQL
conn = connect(Postgres, "localhost", "username", "password", "dbname", 5432)
stmt = prepare(conn, "SELECT 1::bigint, 2.0::double precision, 'foo'::character
varying, " *
"'foo'::character(10);")
result = execute(stmt) # this was missing in your use!
df = fetchdf(result)
finish(stmt)
disconnect(conn)
Perhaps that helps clarify? Happy to help further, here or offline.
Cameron