View Full Version : install Postgress
NewsArchive
12-20-2013, 11:57 AM
Hello,
I am using SB to install Postgres along with my app - this works fine. But I
am trying to create a new database in Postgres via SB script and having a
problem.
I am using SB run program with this result:
run C:\PG\bin\createdb.exe -h localhost -p 5432 -D pg_default -T
template0 -E WIN1252 -O postgres newdbname
This works fine as far as calling and running createdb.exe but I am always
prompted for a password. If I enter the password (during the SB install
running) then the database is properly created so I know my command line is
correct. But I want to make this password-entry free and did some research
on createdb. Supposedly, I can set the Postgres environmental variable
PGPASSWORD to the proper password before createdb is run and I will not be
asked for a password.
I use SB to set the PGPASSWORD environmental variable just before running
createdb but it does not work - still asked for a password.
Anyone have any suggestions?
regards,
Chuck
NewsArchive
12-20-2013, 11:58 AM
Chuck,
I Googled a bit and there are tons of messages with regard to this Postgres
password prompt. As far as I can see, you have to set the PGPASSWORD
environment variable for the **current** process and not edit the PGPASSWORD
variable value per-se (because this requires a reboot).
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686206(v=vs.85).aspx
In other words, you have to call the SetEnvironmentVariable Windows API from
the installer.
Friedrich
NewsArchive
12-21-2013, 07:42 AM
Friedrich,
doing a Windows API call with "call dll" in SB I am doing this:
library = kernel32.dll
function = SetEnvironmentVariable
convention = __stdcall
parameter types = ???
function parameters = "PGPASSWORD", "MyPassword"
I need to know the parameter types. Is the reset okay?
regards,
Chuck
NewsArchive
12-21-2013, 07:43 AM
it is SO easy to create a DB from sql code : create a clarion dll and
call it ?
connect to postgress db and then send a simple create database etc ....
--
JP
__________________________________________________ _____
For those who do not understand ... : "Qui bene amat bene castigat."
__________________________________________________ _____
DMC - Data Management Center : a tool to let you Migrate Import Export
Transfer your Data
www.dmc-fr.com
NewsArchive
12-21-2013, 02:21 PM
JP,
So assume I know zilch about SQL - I have already used SB to install
Postgres and the ODBC driver - that is all good. From the SB script I then
run a Clarion app that uses FM3 to create the empty database - this works
fine, but only if the database exists in Postgres already. I only need to
supply the FM3 SQL_Connect procedure with the database name, owner, server,
port, schema name, and password.
My dilemma is how to create the Postgres database first before the FM3 stuff
happens - and I do not know how to do this. How would I create the Postgres
database in my Clarion app that is run from SB? How do I send the connection
string and CREATE DATABASE commands to Postgres, from my own Clarion code?
regards,
Chuck
NewsArchive
12-23-2013, 05:26 AM
Forget about FM 3when you use SQL - it is NOT meant for such things
The postgress DB already exists when installed
the postgress user already exists when installed
the inatllation should define - you - the password
connect to that DB and create YOURS.
very simple when using the proper tools.
from any clarion "dll" called from your SB installer you connect to the
postgress DB with the postgress user and pwd then create YOUR db and
also YOUR user to use for YOUR client and you give him ONLY THAT user
to access YOUR DB, see ?
This is security.
--
JP
__________________________________________________ _____
For those who do not understand ... : "Qui bene amat bene castigat."
__________________________________________________ _____
DMC - Data Management Center : a tool to let you Migrate Import Export
Transfer your Data
www.dmc-fr.com
NewsArchive
12-23-2013, 05:27 AM
Chuck,
I use SB to create the initial database, but I use psql command line to
execute sql instead of the createdb command.
The sql I use (assuming mydb is your new database):
-- filename: CreateDatabase.sql
-- Database: mydb
DROP DATABASE IF EXISTS mydb;
CREATE DATABASE mydb
WITH OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default;
....jack
--
********************************************
Who: L Jack Wilson
Where: ljwilson@dNiOgSiPtAaMlav.com
How: Remove Capital Letters from above for a valid email address
Why: Standard Disclaimer fits nicely here.
NewsArchive
12-23-2013, 05:27 AM
Jack,
I am trying to get this all to work without any user input - in other words,
create the new database via code, either in SB or my Clarion code.
I tried RUNning createdb.exe in SB and a command line but cannot get it to
work without being required to enter a password.
So now I am trying to use prop:sql or Send() in my code after creating a
connection string. Still working on it.
regards,
Chuck
NewsArchive
12-23-2013, 05:27 AM
Chuck,
Understood. The user does not have to enter a password using the sql
script I gave you.
...jack
--
********************************************
Who: L Jack Wilson
Where: ljwilson@dNiOgSiPtAaMlav.com
How: Remove Capital Letters from above for a valid email address
Why: Standard Disclaimer fits nicely here.
NewsArchive
12-23-2013, 05:28 AM
Initially you can use the Postgres database, it always exists and if you
use /turbosql you dont need to define a table.
Use that to connect, create your database, disconnect and reconnect
using the creted db for FM3
Sean H
NewsArchive
12-23-2013, 05:28 AM
Sean,
Thanks - I did exactly that. Being new to SQL, it me took a little while to
figure out the correct method and syntax to create the new database but I
finally got it.
regards,
Chuck
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.