How to create a PostgreSQL DATABASE Programatically

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

How to create a PostgreSQL DATABASE Programatically

Post 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 :)
With best regards,
Sudip
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: How to create a PostgreSQL DATABASE Programatically

Post 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
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: How to create a PostgreSQL DATABASE Programatically

Post 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!!!
Luigi from Italy
www.L3W.it
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: How to create a PostgreSQL DATABASE Programatically

Post by sudip »

Hi Luigi,

Thanks a lot :D
With best regards,
Sudip
Post Reply