Forum > Databases
The SQLdb Port do Connect
El Muerte:
Hi all,
I looked up for the properties where I can change the port to connect to the postgre database and i didnt find it!
How may I change the port to connect to postgre using SQLdb package?
thanks
Anonymous:
You know at first I thought how silly. But then I started looking I don't know where I can change the port address. On monday I'll ask on the IRC. Joost might shed some light.
John
johnf:
I contacted Joost and he showed me where the port address can be provided. The params of the connect is where you assign the port. If you look at pqconnection.pp you will see:
procedure TPQConnection.DoInternalConnect;
var msg : string;
begin
{$IfDef LinkDynamically}
InitialisePostgres3;
{$EndIf}
inherited dointernalconnect;
FConnectString := '';
if (UserName <> '') then FConnectString := FConnectString + ' user=''' + UserName + '''';
if (Password <> '') then FConnectString := FConnectString + ' password=''' + Password + '''';
if (HostName <> '') then FConnectString := FConnectString + ' host=''' + HostName + '''';
if (DatabaseName <> '') then FConnectString := FConnectString + ' dbname=''' + DatabaseName + '''';
if (Params.Text <> '') then FConnectString := FConnectString + ' '+Params.Text;
FSQLDatabaseHandle := PQconnectdb(pchar(FConnectString));
The Params.Text would need to contain something like "port=????"
Hope this helps.
Anonymous:
I tryed this:
Datamodule1.PQConnection1.Params.Text:='port=8000';
didnt worked....
any more idea?
Anonymous:
I suggest you submit this question to the mailing list.
BTW I have not had any success using a datamodule. You may want to try creating a test form and add a connection for testing. Also I did not test myself. I wonder if the 'FconnectString'
requires something different than what I suggested. You could compile the FPC with debug on and place a break point and see what the actual 'FConnectionString' looks like.
Maybe it is structured differently than I suggested.
John
Navigation
[0] Message Index
[#] Next page