question on dub and postgresql

Imperatorn johan_forsberg_86 at hotmail.com
Mon Oct 5 15:52:47 UTC 2020


On Monday, 5 October 2020 at 13:30:22 UTC, Alaindevos wrote:
> On Monday, 5 October 2020 at 11:35:43 UTC, Imperatorn wrote:
>> On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote:
>>> [...]
>>
>> 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 ?

Is this the first time you are trying D?


More information about the Digitalmars-d-learn mailing list