October 05, 2020 Re: question on dub and postgresql | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alaindevos | 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?
|
October 05, 2020 Re: question on dub and postgresql | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alaindevos | On 10/5/20 6:01 AM, Alaindevos wrote:
> On Monday, 5 October 2020 at 09:24:33 UTC, Mike Parker wrote:
>> On Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote:
>>
>>> [...]
>>
>> You don't need to install dpq2 if you are using dub to build your project. Add it as a dependency to your dub.json (or dub.sdl if you prefer that format). When you build your project, dub will download the version you configured as your dependency and compile it along with your project.
>>
>> [...]
>
> Thanks for this clear explanation. I'll try first using the dub tooling.
> PS : Manual does not look easy with different versions in the /home/myhome/.dub/packages directory.
dub will automatically download any version that is used as a dependency. You don't have to worry about it.
So let's say one project depends on version 2.0.0 of a package, and another depends on 1.0.0. Both will be downloaded, compiled, and used as the appropriate dependency that the project requests.
Compare to a build system where you need to install the dependencies manually, now you have to install the right one to get the right version.
However, keep in mind that dub only deals with D packages, not external dependencies (like libpq, which is required for dpq2).
-Steve
|
October 05, 2020 Re: question on dub and postgresql | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alaindevos | On 10/5/20 11:42 AM, Alaindevos wrote:
>> Use "rangify" template to get forward range from answer
> Thanks, this answers the question on programmatic level.
> Yet I guess something is special with the answer datatype which makes foreach to fail.
Instead of thinking of it as "foreach failing," instead consider that the library author did not implement foreach.
|
October 07, 2020 Re: question on dub and postgresql | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alaindevos | On Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote:
> On Monday, 5 October 2020 at 08:54:39 UTC, Daniel Kozak wrote:
>> On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote:
>>
>>>[...]
>>
>> Yes and no. Dub is Dlang dependency solution but it is not installer as pip is
>>
>>
>>>[...]
>>
>> Yes if you want to use any of dub packages you need to add it as a dependency to your dub.json (dub.sdl)
>
> A name dependency solution is at least vage.
> How do I install ,
> https://github.com/denizzzka/dpq2
> on unix so in the code i write the .d files of that library and after compilation linked to the libary shared objects. For that shared object must be installed. How ?
It seems the D ecosystem is not immediately obvious to some people. Dub, compilers, and IDEs are recurring issues.
|
October 07, 2020 Re: question on dub and postgresql | ||||
---|---|---|---|---|
| ||||
Posted in reply to aberba | On Wed, Oct 07, 2020 at 07:15:42PM +0000, aberba via Digitalmars-d-learn wrote: [...] > It seems the D ecosystem is not immediately obvious to some people. Dub, compilers, and IDEs are recurring issues. This is stuff that needs to be documented up-front and in-your-face. For example, if we're going to be serious about dub, all code examples on the front page of dlang.org ought to use it. Invocation syntax should be shown right there on the front page. It should permeate all documentation and frequently alluded to. Similarly, if we're serious about code.dlang.org, then it also needs to permeate all code examples on dlang.org throughout. It needs to be treated as first-class citizen. Otherwise, it can only be perceived as this nebulous side thing of unclear relevance that people will tend to ignore. T -- Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. -- Gene Wirchenko |
October 08, 2020 Re: question on dub and postgresql | ||||
---|---|---|---|---|
| ||||
Posted in reply to aberba | On Wednesday, 7 October 2020 at 19:15:42 UTC, aberba wrote:
> It seems the D ecosystem is not immediately obvious to some people. Dub, compilers, and IDEs are recurring issues.
and debbuging (particularly inspection)
|
October 08, 2020 Re: question on dub and postgresql | ||||
---|---|---|---|---|
| ||||
Posted in reply to ddcovery | I found dub.json has very important info, To name three : importPaths , libs , dependencies. When these are right you have started for 80%. Without nagging, when you begin you are however lost in the woods and it makes the impression to lose interest completely. For ease there is : targetName, targetPath, sourcePaths. What is also quite annoying is links to libraries which are unmaintained. E.g. sql-libraries where no code check-in has been done for almost ten years. |
Copyright © 1999-2021 by the D Language Foundation