Stream
Stream

Reputation: 89

Run Batch File In postgresql in single click

Hello Experts I have made batch file to run query in postgresql it works fine after pressing enter key 4 times without typing. 1-server, 2 database, 3 port and 4 for password. I need this same result with single click. `

@echo off
REM Copyright (c) 2012-2016, EnterpriseDB Corporation.  All rights reserved

REM PostgreSQL server psql runner script for Windows

cmd.exe /c chcp 1252

SET server=localhost
SET /P server="Server [%server%]: "

SET database=naari
SET /P database="Database [%database%]: "
SET Password=pes

SET port=5432
SET /P port="Port [%port%]: "

SET username=postgres
SET /P username="Username [%username%]: "

for /f "delims=" %%a in ('chcp ^|find /c "932"') do @ SET CLIENTENCODING_JP=%%a
if "%CLIENTENCODING_JP%"=="1" SET PGCLIENTENCODING=SJIS
if "%CLIENTENCODING_JP%"=="1" SET /P PGCLIENTENCODING="Client Encoding [%PGCLIENTENCODING%]: "
REM Run psql
"C:\Program Files\PostgreSQL\10\bin\psql.exe" -h %server% -U %username% -d %database% -p %port% -f e:\DELETE.sql
pause

`

Upvotes: 1

Views: 4611

Answers (1)

Stream
Stream

Reputation: 89

Now I have a solutions.

@echo off
REM Copyright (c) 2012-2016, EnterpriseDB Corporation.  All rights reserved

REM PostgreSQL server psql runner script for Windows

cmd.exe /c chcp 1252

REM Run psql
"C:\Program Files\PostgreSQL\10\bin\psql.exe" -h localhost -U postgres -d naari -p 5432 -f e:\script.sql

pause

Upvotes: 1

Related Questions