# Not able to load PostgreSQL into LibPQ.jl

**URL:** <https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767>\
**Category:** Data\
**Tags:** question, package, postgresql, sql\
**Created:** [September 26, 2021, 12:14am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767 "2021-09-26T00:14:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 12:14am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/1 "2021-09-26T00:14:53Z")

</div>

I have installed postgressql, and am trying to use the LibPQ.jl . But, when I try to connect

```julia
conn = LibPQ.Connection("dbname=postgres user=BrettKnoss)

```

I’m told that.

```julia
conn=

could not connect to server: No such file or directory

```

Do I need to go into PostgressQL from my terminal, or set up a root file, in order to connect to a database?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 12:43am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/2 "2021-09-26T00:43:38Z")

</div>

Is Postgres running on your system before you try to to connect to it?  
If you are using Postgres regularly, your system should be set up to start the database server with each reboot of your computer. Did you install PostgreSQL yourself? Usually the installation process sets up the automatic starting of its server. If you have done this, and have not yet restarted the computer, try doing that.

then try

```julia
using LibPQ, Tables

conn = LibPQ.Connection("dbname=postgres") # omit username for now
result = execute(conn, "SELECT typname FROM pg_type WHERE oid = 16")
data = columntable(result)

```

If that works, and this does not work

```julia
using LibPQ
conn = LibPQ.Connection("dbname=postgres user=BrettKnoss")

```

then the problem is that you have not set yourself up as user that Postgres recognizes (it seems).

Are you able to do anything using Postgres directly? The database system usually is distributed with a user interface tool that allows one to create new tables and most anything else. It is a useful way to confirm that your system is set up properly for this purpose.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 1:03am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/3 "2021-09-26T01:03:05Z")

</div>

> [@JeffreySarnoff](#):
>
> ```julia
> conn = LibPQ.Connection("dbname=postgres") # omit username for now
> result = execute(conn, "SELECT typname FROM pg_type WHERE oid = 16")
> data = columntable(result)
> 
> ```

It didn’t connect. I don’t think Postgres is running, but how do I check and make sure that it is?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 1:12am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/4 "2021-09-26T01:12:48Z")

</div>

Well … it sounds like you already know 🙂  
I need some more information to answer your question:

- What does `julia> versioninfo()` show?
- What is the exact distribution of PostgreSQL that you obtained?
  - where from (the url linking to the file or a webpage and filename)

- What did you do when you attempted to install Postgres?
- Are you a user or an administrator on the computer system you use?
  - (is it your personal machine, or is it managed for you, or both?)

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 1:23am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/5 "2021-09-26T01:23:51Z")

</div>

```julia
Julia Version 1.7.0-rc1
Commit 9eade6195e (2021-09-12 06:45 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-1630 v3 @ 3.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, haswell)

```

OS: ubuntu 20.04 LTS

I am on a Personal Machine, and this is for personal experimentation/play

How do I find the distribution and version of Postgress, that I have?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 1:48am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/6 "2021-09-26T01:48:50Z")

</div>

Much of what follows transpires from within your terminal window.  
To open the terminal in Ubuntu, press Ctrl+Alt+T (or find the terminal entry in the menu).

Before looking for stuff, let’s make sure your software is up to date and you have the Synaptic Package Manager (it is an easier way to deal with Ubuntu packages, and keeps things happy) In the terminal (assuming your prompt is `$`, type

```julia
$ sudo apt update
$ sudo apt-get install synaptic

```

Those lines will have output …  
once completed, start the Synaptic Package Manager (there should be an entry in the menu (or some submenu)  
You should see a user interface for the package manager.

In the search field, enter postgresql  
there are many that start postgres, just scroll until you see what appears to be the default / current release and look to see if that has been installed (look at the installed version column, are any postgres’s installed?).

Do not check anything to be installed at this moment.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 2:13am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/8 "2021-09-26T02:13:52Z")

</div>

in the terminal (Ctrl+Alt+T) you can type  
`$ apt show postgresql` and see if postgresql is known  
let me see the response

### this is simpler than copying from the package manager

again in the terminal, let’s make sure you are using the most current releases of the software that is already installed  
`$ sudo apt -y upgrade`

Now we are going to install (or reinstall, or do nothing) postgres and friends. There is no harm if you have these programs installed already. Doing these next steps assures that you will have what you need of postgreSQL. From the terminal:

```julia-auto
$ sudo apt-get install postgresql
$ sudo apt-get install postgresql-client
$ sudo apt-get install postgresql-contrib
$ sudo apt-get install pgadmin4

```

after that is done, you can confirm that PostgreSQL is ready for use (let me know when you get here, or if you encounter something unexpected). Once here, please restart your machine. It is helpful to begin with a clean environment.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 2:49am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/9 "2021-09-26T02:49:44Z")

</div>

This is the first thing that comes up when i search postgres, and it says it’s the backend for PostgresSQL

akonadi-backend-postgresql  
PostgreSQL storage backend for Akonadi

Version: 4:19.12.3-0ubuntu2

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 3:07am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/10 "2021-09-26T03:07:32Z")

</div>

$ sudo apt-get install postgresql

postgresql is already the newest version (13+226.pgdg20.04+1).

$ sudo apt-get install postgresql-client

Preparing to unpack …/postgresql-client\_13+226.pgdg20.04+1\_all.deb …  
Unpacking postgresql-client (13+226.pgdg20.04+1) …  
Setting up postgresql-client (13+226.pgdg20.04+1) …  
postgresql-contrib is already the newest version (13+226.pgdg20.04+1).

$ sudo apt-get install postgresql-contrib

postgresql-contrib is already the newest version (13+226.pgdg20.04+1).

$ sudo apt-get install pgadmin4

Package pgadmin4 is not available, but is referred to by another package.  
This may mean that the package is missing, has been obsoleted, or  
is only available from another source

E: Package ‘pgadmin4’ has no installation candidate

As you can see, postgressql and postgressql-client are the latetst version, while pgadmin4 did not install (I think this is obsolete). I’m not sure how to test if postgresql-contrib has installed properly.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 3:10am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/11 "2021-09-26T03:10:02Z")

</div>

when I go to [https://www.pgadmin.org](https://www.pgadmin.org) , it shows that Pgadmin 4 v5.6 was released in August

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 3:15am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/12 "2021-09-26T03:15:11Z")

</div>

```julia
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

```

gives a security error and notifications

```julia
E: The repository 'https://download.docker.com/linux/debian focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease' doesn't support architecture 'i386'

```

is i386 something to do with my processor? I’m also not sure that this is the proper Ubuntu version, even though it’s for Debian.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 3:27am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/13 "2021-09-26T03:27:41Z")

</div>

your system is fine – open synaptic package manager and search for pgadmin – there should be something that begins with “pgadmin”, if there is, move the mouse cursor onto the most recent version and click it (agree to install it, then press the “doit” button (I don’t recall – maybe its actions or tasks).  
if you are asked if you want to include additional related packages say yes

also look for pgadmin?-apache2

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 3:33am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/14 "2021-09-26T03:33:08Z")

</div>

How do I go I get admin privledges in synaptic?

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 3:33am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/15 "2021-09-26T03:33:40Z")

</div>

I did find I have pgadmin3 , could that create a conflict?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 3:36am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/16 "2021-09-26T03:36:28Z")

</div>

do not use pgadmin3  
there is a better alternative, again in the terminal

```julia
sudo snap install dbeaver-ce

```

that should give you Dbeaver which is a cross-platform database front end that works well. Try to start it (from the menu or the terminal. What happens?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 3:37am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/17 "2021-09-26T03:37:42Z")

</div>

I am not on Linux right now – you could try  
`$ sudo synaptic`  
the “sudo” command means “treat me as the admin for this”

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 3:38am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/18 "2021-09-26T03:38:10Z")

</div>

I was able to get to synaptic froomm the desktop with admin, and am downloading/installing pgadmin4

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 3:39am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/19 "2021-09-26T03:39:30Z")

</div>

good  
At some point you will be prompted for a username and password by PostgreSQL. Keep it simple, for now, avoid spaces in the username e.g. “BrettKnoss”. Keep the default name of “postgres”.

what did you do last?

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [September 26, 2021, 3:41am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/20 "2021-09-26T03:41:31Z")

</div>

Do I add a new server?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 26, 2021, 3:43am UTC](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767/21 "2021-09-26T03:43:20Z")

</div>

see

> **[pgAdmin 4 — pgAdmin 4 7.7 documentation](https://www.pgadmin.org/docs/pgadmin4/latest/index.html)**
>
> pgAdmin - PostgreSQL Tools for Windows, Mac, Linux and the Web

and particularly

> **[Desktop Deployment — pgAdmin 4 7.7 documentation](https://www.pgadmin.org/docs/pgadmin4/latest/desktop_deployment.html#desktop-runtime-standalone-application)**
>
> pgAdmin - PostgreSQL Tools for Windows, Mac, Linux and the Web

and for the server

> **[Connecting To A Server — pgAdmin 4 7.7 documentation](https://www.pgadmin.org/docs/pgadmin4/latest/connecting.html)**
>
> pgAdmin - PostgreSQL Tools for Windows, Mac, Linux and the Web

basic guideline: do as little as possible, just enough to get yourself connected and talking to the database system

[Next page](https://discourse.julialang.org/t/not-able-to-load-postgresql-into-libpq-jl/68767.md?page=2)
