1

So I have a file which I want a beginning section to tear down a db if exists, then create one and connect to it.

Thus far I have:

Drop DATABASE IF EXISTS db_name;
CREATE DATABASE db_name;
<don't know what goes here to connect to db_name>

I have googled a lot and keep finding how to do it from the psql command prompt but not how to connect like I am looking to do from a file.

Any help would be appreciated.

sourlain
  • 125
  • 8
  • use is mysql not postgresql. – sourlain May 26 '15 at 16:07
  • well, the pg-specific `\c db_name`, then? – Marc B May 26 '15 at 16:37
  • The question was marked as a duplicate incorrectly. Its author has clearly stated that he is looking for a different solution than provided in the "duplicated" question. @sourlain probably you could try `dblink` extension, though that would hardly be a clean solution I think. – volvpavl Feb 27 '19 at 10:01

0 Answers0