How do I create a Postgres database in Perl?
1 answer
The trick is using the postgres database, which you are likely to have when installing Postgres (if you don't have a postgres database, you probably know why). If you are connecting as user "postgres" to the postgres database, you can then run the create database SQL command , for example:
my $dbh = DBI->connect("dbi:Pg:dbname=postgres", "postgres");
$dbh->do('create database "Scratch-School"');
(You can also look at creating a postgreSQL database programmatically , which covers this issue at a higher level.)
+4
source to share