Skip to content
Advertisement

How to fix syntax error at or near “psql” in psql ubuntu

I am entirely new to psql and not particularly familiar with some terms. I am following instructions on an ETL process for mimic-in the link here: https://github.com/chichukw/mimic-omop/blob/master/README-run-etl.md. When I run this code, it shows no output but this error:

syntax error at or near “psql”

I have tried adding semicolon, removing the psql part and removing the quotes and dollar sign but I still get this syntax error on the first character regardless. enter image description here

psql "$MIMIC" postgres_create_mimic_id.sql; 

I expect concept ids to be created after running this code on the server using the jupyter terminal.

Advertisement

Answer

The only way I can think of how you could get that output/error is if you did this:

[root@foo /]# psql
psql (11.5)
Type "help" for help.

postgres=# psql "$MIMIC" postgres_create_mimic_id.sql; 
ERROR:  syntax error at or near "psql"
LINE 1: psql "$MIMIC" postgres_create_mimic_id.sql;
        ^
postgres=# 

Instead, I think you should be doing this:

[root@foo /]# export MIMIC='host=localhost dbname=postgres user=postgres options=--search_path=mimiciii'
[root@foo /]# psql "$MIMIC" -f postgres_create_mimic_id.sql;

Disclosure: I am an EnterpriseDB (EDB) employee

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement