#Can't run sql query trying to create a postgreSQL Database

44 messages · Page 1 of 1 (latest)

dense starBOT
#

Project ID: 4b8c2a06-3558-485f-a3a2-ea8afa7e9787

mint ruin
#

4b8c2a06-3558-485f-a3a2-ea8afa7e9787

mint ruin
grizzled kernel
#

that is absolutely not a valid query

mint ruin
#

now im doing it one by one and it running okay

#

until this line

#

COPY public.categorias (id_categoria, nombre) FROM stdin; 1 Dormitorio 2 Comedor 3 Cocina 4 Oficina 5 Living 6 Infantil - syntax error at or near "1"

#

COPY public.categorias (id_categoria, nombre) FROM stdin;
1 Dormitorio
2 Comedor
3 Cocina
4 Oficina
5 Living
6 Infantil
.

mint ruin
#

im pastingit from my sql file so i dont undertaand whatsa wrong?

grizzled kernel
#

that's not a valid query either

mint ruin
#

why?

#

im taking it from the query that was made automatically by doing a backup from postgresql

grizzled kernel
#

you want to to use pg_restore

mint ruin
#

what do you mean?

grizzled kernel
mint ruin
#

ahhhh yes!! is did a dump

#

so the dump generated me an script with the full query

#

So now i need to do a restore in the query?

grizzled kernel
#

did you use pg_dump?

grizzled kernel
mint ruin
#

Yes

grizzled kernel
#

then use pg_restore

mint ruin
#

i was checking

#

and that command will make me another file with a different query?

grizzled kernel
#

no, it restore the database from the dump

grizzled kernel
mint ruin
#

okay, cool i will check it now thanks for the help 😉

mint ruin
#

pg_restore -U <Username> -d <database_name> <file_path>.sql

#

is this correct doing it from my pc?

#

DATABASE_URL
PGDATABASE = database_name?
PGHOST
PGPASSWORD
PGPORT
PGUSER = Username?

mint ruin
#

C:\Program Files\PostgreSQL\15\bin>pg_restore -U postgres -d railway mueblesmayo.sql
pg_restore: error: input file does not appear to be a valid archiver

grizzled kernel
#

oh you have a .sql file, in that case you want psql

mint ruin
#

i dont really understand what are the steps i need to follow 😦

#

I have my database created in my pg admin 4 in my computer

#

i did a pg_dump in my computer so now i have a file with the sql code to create that database

#

but now, what i need to do to create that database in railway

grizzled kernel
#

you have a .sql file, so you need psql

#

maybe watch some youtube videos?

mint ruin
#

I solved it, sorry for bothering i was just mixing all

#

the way you told me was ok, thanks again and sorry