JuliaΒΆ

Connect to CrateDB from Julia applications.

About

LibPQ.jl is a Julia wrapper for the PostgreSQL libpq C library.

Synopsis

setup.jl

using Pkg
Pkg.add("LibPQ")
Pkg.add("Tables")

example.jl

using LibPQ
using Tables

conn = LibPQ.Connection("postgresql://crate:crate@localhost:5432/?sslmode=disable");
result = LibPQ.execute(conn, "SELECT mountain, region, height FROM sys.summits ORDER BY height DESC LIMIT 3")
data = rowtable(result)
for row in data
    println(row)
end

Start CrateDB using Docker or Podman, then invoke the example program.

docker run --rm --publish=5432:5432 docker.io/crate '-Cdiscovery.type=single-node'
julia setup.jl
julia example.jl

SSL connection

Use the sslmode=require parameter, and replace username, password, and hostname with values matching your environment. Also use this variant to connect to CrateDB Cloud.

conn = LibPQ.Connection("postgresql://admin:password@testcluster.cratedb.net:5432/?sslmode=require");

Learn