question on dub and postgresql

Alaindevos devosalain at ymail.com
Mon Oct 5 13:30:22 UTC 2020


On Monday, 5 October 2020 at 11:35:43 UTC, Imperatorn wrote:
> On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote:
>> On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote:
>>> On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:
>>>> [...]
>>>
>>> Take a look at:
>>> https://code.dlang.org/packages/dpq2
>>> https://code.dlang.org/packages/ddbc
>>
>> Say I want to use dpq2.
>> Do I need to clone the git repository with "git clone ?"
>
> No, you just dub add dpq2

With dub.json:
"dependencies": {
		"dpq2": "~>1.0.17"
	},
It worked.
Something I ask myself is how do I pass a connection from one 
function to another.
...
string url=format("hostaddr='127.0.0.1' port='5432' dbname='%s' 
user='%s' password='%s'",db,user,pass);
  writeln(url);
Connection conn = new Connection(url);
auto answer = conn.exec("SELECT version()");
writeln(answer[0][0].as!PGtext);
...
myfunction(conn)

void myfunction( .... conn)
What is the type I should use for passing conn ?



More information about the Digitalmars-d-learn mailing list