Not able to load PostgreSQL into LibPQ.jl

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

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

I’m told that.

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?

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

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

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.

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

Well … it sounds like you already know :slight_smile:
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?)
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?

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

$ 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.

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:

$ 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.

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

$ 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.

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

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

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.

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

How do I go I get admin privledges in synaptic?

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

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

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?

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

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

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?

Do I add a new server?

see

and particularly

and for the server

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