0

Hi and thanks in advance. I am currently exporting from my postgres database VIA the psql shell with::

    \COPY "Accounts" TO 'C:\Users\admin\Desktop\Accounts.csv' CSV HEADER;

This works fine, but I want to be able to double click a batch file .cmd or .bat that is saved on my desktop to 1) log into the database 2) export the CSV. So that way I dont have to go into psql shell every time. Please help, I did google but postgres resources are few.

Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • 2
    And what keeps you from doing that? –  May 04 '16 at 21:56
  • When posting here, you will generally get a warm and helpful response so long as you have tried to create the solution first and then post showing where you got stumped. Try updating your post once you have done this. – John Mark Mitchell May 04 '16 at 23:23
  • @a_horse_with_no_name I am on a Windows machine with Postgres installed. I do not know the syntax/how to do this. I am new to coding. I want to connect to the database then run that SQL command, just by double clicking one file. i'm assuming its a batch file but I do not know enough. Any help is appreciated. thank you. – Funky Dude May 04 '16 at 23:24
  • Ahhh, windows...batch. You tagged this with the tag BASH. That is a scripting language for linux, mac and in rare cases windows. If using Windows you probably want a powershell script. – John Mark Mitchell May 04 '16 at 23:29

1 Answers1

0

Because the comments above are limited in their length and formatting, I am sharing some basic research that might get you started:

Community
  • 1
  • 1
John Mark Mitchell
  • 4,522
  • 4
  • 28
  • 29