Below is ISQL query, which has column width -w and column seperator -s option can someone help with psql query for the same?
isql -U$username -P$PASSWORD -S$server -i/tmp/abc **-s~ -w500** > /tmp/xyz
psql -U $username -h $server -p $PORT -w -f /tmp/abc > /tmp/xyz
This shall be psql query but not sure about option -s and -w.
Related
Error - ERROR: schema "public" already exists when running psql to load a sql dump file into database.
PGPASSWORD=xyzabc pg_dump -U postgres -h cloudsql-proxy -p 3306 -d development -n public --format=p >/dev-db/devBackup.sql
export PGPASSWORD=postgres
psql -U postgres -h local-dev-db -p 5432 --dbname pangea_local_dev -c 'CREATE EXTENSION IF NOT EXISTS citext with schema public;'
psql -U postgres -h local-dev-db -p 5432 pangea_local_dev -1 -n public -f /dev-db/devBackup.sql
I try to translate this command with Powershell Core
docker run --rm -e PGPASSWORD=$Env:PGPASSWORD postgres:14.2 pg_restore --clean -d db -h mydb.com -U sa --format=custom < pg.dump
And I have this error
The '<' operator is reserved for future use.
I've tried many things like
echo pg.dump | docker run --rm -e PGPASSWORD=$Env:PGPASSWORD postgres:14.2 pg_restore --clean -d db -h mydb.com -U sa --format=custom
pg_restore: error: could not read from input file: end of file
echo pg.dump | docker run --rm -e -it PGPASSWORD=$Env:PGPASSWORD postgres:14.2 pg_restore --clean -d db -h mydb.com -U sa --format=custom
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'
I can't find how to use the stdin operator with Powershell Core
Try to change sequence of your actions. Run container -> Copy backup file into container -> Run command pg_restore
Here is an algorithm (not the working code) to execute in powershell. Note that docker cp may work only with container id. You can get it if you parse it via docker ps | Select-String -Pattern "my_postgres"
Set-Location "C:\postgres_backup"
Write-Output "Starting postgres container"
docker run --rm --name=my_postgres --env PGPASSWORD=$Env:PGPASSWORD postgres:14.2
Write-Output "Copying backup to container"
docker cp ./pg.dump my_postgres:/pg.dump
Write-Output "Execute something in postgres container"
docker exec -i $my_postgres pg_restore --clean -d db -h mydb.com -U sa --format=custom -1 pg.dump
I need a tshark command so i can create a txt file containing Ipsource>Ipdestination:Info in this order ! i tried this command
tshark -T fields -n -r "C:\Users\dell\Desktop\tracecomplete.pcap" -E separator=, -e ip.src -e ip.dst > "C:\Users\dell\Desktop\walima22.txt"*
but i can't change the separator and show the infos
There are generally 2 solutions for printing specific column data, one using column-specifiers and the other using fields, similar to what you have.
Using column-specifiers:
Standard specifiers as described by tshark.exe -G column-formats:
tshark.exe -n -r "C:\Users\dell\Desktop\tracecomplete.pcap" -o "gui.column.format:\"Source\",\"%s\",\"Destination\",\"%d\",\"Info\",\"%i\""
... or using custom columns for those fields that are supported:
tshark.exe -n -r "C:\Users\dell\Desktop\tracecomplete.pcap" -o "gui.column.format:\"Source\",\"%Cus:ip.src\",\"Destination\",\"%Cus:ip.dst\",\"Info\",\"%i\""
Using Fields:
tshark.exe -n -r "C:\Users\dell\Desktop\tracecomplete.pcap" -T fields -E separator=, -e ip.src -e ip.dst -e _ws.col.Info
but i can't change the separator
You should be able to change it using the -E option. Refer to the tshark man page for more help with this option.
docker exec -it CONTAINER_ID psql -U postgres -d DB -c "select 1" > /dev/null 2>&1
How do I get the output of select 1 in the terminal?
Try this:
docker exec CONTAINER_ID bash -c "psql -U postgres -d DB -c \"select 1\" "
My command prompt has the following structure:
psql -d databasename -h hostname -p portnumber -U username -w -f batchfile\location\here
I get the following error:
ERROR: syntax error at or near "ï>>¿"
LINE 1: ï>>¿
This causes the first sql query in the batch to not run.
I don't seem to have any problems when executing a batch file using <. See example below:
psql -d databasename -h hostname -p portnumber -U username -w < batchfile\location\here
I'm running postgreSQL version 8.2.15.
Is there something in the command line or the sql batch that I need when using -f? Thanks in advance!