Page 1 of 1

How to create a PostgreSQL DATABASE Programatically

Posted: Sun Nov 14, 2010 3:53 pm
by sudip
Hello All,

How to create a PostgreSql database programatically, so that our app can check whether the database exists or not. If it doesn't exist, it will create the database.

I did it with MySql and SQLite. But I don't know how to do it with PostgreSQL.

Because we have to pass the database name in DbPGConnection() function.

Thanks in advance :)

Re: How to create a PostgreSQL DATABASE Programatically

Posted: Mon Nov 15, 2010 11:18 am
by l3whmg
Hi Sudip,
I think you can read "contrib\hbpgsql\tests\simple.prg" on harbour distribution package.
I've done some experience with PostGreSql and I prefer to create the database with the tool pgadmin (I think about user privilegies, etc); instead for tables I use the SQL language.
I've worked with Harbour PgSql contrib library.

Best regards

Re: How to create a PostgreSQL DATABASE Programatically

Posted: Mon Nov 15, 2010 11:33 am
by l3whmg
Hi Sudip,
I've read on internet (developer PostGreSql) you can connect with DbName as the user name; other way connect the templates databases.
Then you can create database
I don't try!!!

Re: How to create a PostgreSQL DATABASE Programatically

Posted: Tue Nov 16, 2010 6:13 am
by sudip
Hi Luigi,

Thanks a lot :D