Accessing Postgresql via Julia

question

#1

I am currently using R to access a remote Postgresql database, and my code looks like those as below:

library(RPostgres)
wrds <- dbConnect(Postgres(), 
                  host='wrds-pgdata.wharton.upenn.edu',
                  port=9737,
                  user='username',
                  password='password',
                  sslmode='require',
                  dbname='wrds')

I would like to know how to do it in Julia.


#2

Have a look at this thread where people helped me a lot:
https://discourse.julialang.org/t/lack-of-stable-postgresql-communication-a-major-showstopper/?source_topic_id=7031


#3

ODBC.jl provides access to any database that supports an ODBC driver; Postgres has excellent support for ODBC. For windows, I’d downloads the msi folder version for an easy installer, for other unix platforms, just grab the tarball from the src directory. You can setup an ODBC dsn file like the one used for testing, which can be registered w/ your system ODBC via the command odbcinst -i -s -h -f ./test/pgtest.odbc.ini.

As noted elsewhere, it takes a bit more setup, but once you’ve been thru it once or twice, I find it much easier to setup any other database.


#4

By the way, on ODBC master on 0.6.1 I’m getting

ERROR: LoadError: LoadError: LoadError: UndefVarError: @isdefined not defined
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:576
 [2] include(::String) at ./sysimg.jl:14
 [3] include_from_node1(::String) at ./loading.jl:576
 [4] include(::String) at ./sysimg.jl:14
 [5] include_from_node1(::String) at ./loading.jl:576
 [6] eval(::Module, ::Any) at ./boot.jl:235
 [7] _require(::Symbol) at ./loading.jl:490
 [8] require(::Symbol) at ./loading.jl:405

#5

Just want to see if there is any update on this