How to get ODBC to work with postgresql


#1

Operating system: Debian Testing/Sid
Julia version: 4.7.2 and 0.6.0-pre.beta.91. The same happens on both versions.

I have installed unixodbc and odbc-postgresql and can connect to my database with isql.

Following the instructions for ODBC.jl the following happens:

using DataFrames
using ODBC

INFO:
Precompiling module DataFrames.
WARNING: Method definition ==(Base.Nullable{S}, Base.Nullable{T}) in module Base at nullable.jl:244 overwritten in module NullableArrays at /home/js/.julia/v0.6/NullableArrays/src/operators.jl:128.
INFO: Recompiling stale cache file /home/js/.julia/lib/v0.6/DataStreams.ji for module DataStreams.
WARNING: Method definition ==(Base.Nullable{S}, Base.Nullable{T}) in module Base at nullable.jl:244 overwritten in module NullableArrays at /home/js/.julia/v0.6/NullableArrays/src/operators.jl:128.
WARNING: ccall: wrong number of arguments to C function in API
WARNING: ccall: wrong number of arguments to C function in API

list installed ODBC drivers

ODBC.listdrivers()

3×2 Array{String,2}:
_ “MDBTools” … “Description=MDBTools Driver\0Driver=libmdbodbc.so\0Setup=libmdbodbc.so\0FileUsage=1\0UsageCount=1\0” _
_ “PostgreSQL ANSI” “Description=PostgreSQL ODBC driver (ANSI version)\0Driver=psqlodbca.so\0Setup=libodbcpsqlS.so\0Debug=0\0CommLog=1\0UsageCount=1\0” _
_ “PostgreSQL Unicode” “Description=PostgreSQL ODBC driver (Unicode version)\0Driver=psqlodbcw.so\0Setup=libodbcpsqlS.so\0Debug=0\0CommLog=1\0UsageCount=1\0”_

list pre-defined ODBC DSNs

ODBC.listdsns()

list pre-defined ODBC DSNs

ODBC.listdsns()​

1×2 Array{String,2}:
_ “PostgreSQL Wos” “PostgreSQL Unicode”_

connect to a DSN using a pre-defined DSN or custom connection string

dsn = ODBC.DSN(“PostgreSQL Wos” ,“PostgreSQL Unicode”, “js”,“xxxxxxxx”)

MethodError: Cannot convert an object of type String to an object of type Ptr{Void}
This may have arisen from a call to the constructor Ptr{Void}(…),
since type constructors fall back to convert methods.

Stacktrace:
_ [1] ODBC.DSN(::String, ::String, ::String, ::String) at /home/js/.julia/v0.6/ODBC/src/ODBC.jl:102_

What is the way forward? There are not Julia Postgresql-drivers that are actively developed as far as I know.

Regards
Johann


#2

I solved the problem after reading about issue #147 on Github using this:

julia> Pkg.rm(“ODBC”)

shell> rm -rf $(Pkg.dir())/.cache/ODBC

julia> Pkg.add(“ODBC”)

julia> Pkg.update()

Regards
Johann