# How to get ODBC to work with postgresql

**URL:** <https://discourse.julialang.org/t/how-to-get-odbc-to-work-with-postgresql/3169>\
**Category:** Data\
**Created:** [April 11, 2017, 1:31pm UTC](https://discourse.julialang.org/t/how-to-get-odbc-to-work-with-postgresql/3169 "2017-04-11T13:31:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johann.spies](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johann.spies/32/8805_2.png) [@johann.spies](https://discourse.julialang.org/u/johann.spies)\
**Post date:** [April 11, 2017, 1:31pm UTC](https://discourse.julialang.org/t/how-to-get-odbc-to-work-with-postgresql/3169/1 "2017-04-11T13:31:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johann.spies](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johann.spies/32/8805_2.png) [@johann.spies](https://discourse.julialang.org/u/johann.spies)\
**Post date:** [April 20, 2017, 9:40am UTC](https://discourse.julialang.org/t/how-to-get-odbc-to-work-with-postgresql/3169/2 "2017-04-20T09:40:16Z")

</div>

> [@johann.spies](#):
>
> dsn = ODBC.DSN(“PostgreSQL Wos” ,“PostgreSQL Unicode”, “js”,“xxxxxxxx”)

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
