digitalmars.D.learn - question on dub and postgresql
- Alaindevos (17/17) Oct 05 2020 Can I say python has pip, ruby has bundle and D has dub.
- Alaindevos (8/26) Oct 05 2020 Some additional question, i struggle with.
- Imperatorn (4/22) Oct 05 2020 Take a look at:
- Alaindevos (3/8) Oct 05 2020 Say I want to use dpq2.
- Alaindevos (8/17) Oct 05 2020 rdmd is as expected unaware of includes and libraries needed.
- Alaindevos (8/26) Oct 05 2020 I cloned the git repository with ,running make does nothing.
- Imperatorn (2/11) Oct 05 2020 No, you just dub add dpq2
- Alaindevos (19/31) Oct 05 2020 With dub.json:
- Alaindevos (2/34) Oct 05 2020 Maybe just Connection ?
- Alaindevos (12/12) Oct 05 2020 Just Connection worked.
- Alaindevos (1/1) Oct 05 2020 answer[0][0].as!PGtext contains good data
- Alaindevos (8/9) Oct 05 2020 I found an answer.
- Mike Parker (6/9) Oct 05 2020 Looking at the implementation of the `Answer` type [1], I see no
- Denis Feklushkin (2/13) Oct 05 2020 Use "rangify" template to get forward range from answer
- Alaindevos (3/4) Oct 05 2020 Thanks, this answers the question on programmatic level.
- James Blachly (3/7) Oct 05 2020 Instead of thinking of it as "foreach failing," instead consider that
- Imperatorn (2/25) Oct 05 2020 Is this the first time you are trying D?
- Daniel Kozak (6/20) Oct 05 2020 Yes and no. Dub is Dlang dependency solution but it is not installer as ...
- Alaindevos (7/31) Oct 05 2020 A name dependency solution is at least vage.
- drug (9/45) Oct 05 2020 Take a look at https://code.dlang.org/packages/dpq2
- Mike Parker (35/41) Oct 05 2020 You don't need to install dpq2 if you are using dub to build your
- Alaindevos (5/13) Oct 05 2020 Thanks for this clear explanation. I'll try first using the dub
- Steven Schveighoffer (11/27) Oct 05 2020 dub will automatically download any version that is used as a
- aberba (3/23) Oct 07 2020 It seems the D ecosystem is not immediately obvious to some
- H. S. Teoh (15/17) Oct 07 2020 This is stuff that needs to be documented up-front and in-your-face. For
- ddcovery (2/4) Oct 08 2020 and debbuging (particularly inspection)
- Alaindevos (10/10) Oct 08 2020 I found dub.json has very important info,
Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? As I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start. [Cfr. in python it is just a "pip install postgres". And you're fine ] Thanks for any info.
Oct 05 2020
On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? As I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start. [Cfr. in python it is just a "pip install postgres". And you're fine ] Thanks for any info.Some additional question, i struggle with. Do i run dub make dub install on git clone ? Or make , make install ? Or it depends on the package provider ? What for vibe ? Which postgresql implementation is best for retreving query results record by record ?
Oct 05 2020
On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? As I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start. [Cfr. in python it is just a "pip install postgres". And you're fine ] Thanks for any info.Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc
Oct 05 2020
On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote:On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:Say I want to use dpq2. Do I need to clone the git repository with "git clone ?"[...]Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc
Oct 05 2020
On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote:On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote:rdmd is as expected unaware of includes and libraries needed. rdmd --build-only test.d test.d(3): Error: module `dpq2` is in file 'dpq2.d' which cannot be read import path[0] = . import path[1] = /usr/local/include/d Failed: ["/usr/local/bin/ldmd2", "-v", "-o-", "test.d", "-I."]On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:Say I want to use dpq2. Do I need to clone the git repository with "git clone ?"[...]Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc
Oct 05 2020
On Monday, 5 October 2020 at 08:50:53 UTC, Alaindevos wrote:On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote:I cloned the git repository with ,running make does nothing. There is no makefile. Dub build spits out, dub build (git)-[master]- Main package must not have target type "sourceLibrary". Cannot build.On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote:rdmd is as expected unaware of includes and libraries needed. rdmd --build-only test.d test.d(3): Error: module `dpq2` is in file 'dpq2.d' which cannot be read import path[0] = . import path[1] = /usr/local/include/d Failed: ["/usr/local/bin/ldmd2", "-v", "-o-", "test.d", "-I."]On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:Say I want to use dpq2. Do I need to clone the git repository with "git clone ?"[...]Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc
Oct 05 2020
On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote:On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote:No, you just dub add dpq2On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:Say I want to use dpq2. Do I need to clone the git repository with "git clone ?"[...]Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc
Oct 05 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: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 ?On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote:No, you just dub add dpq2On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:Say I want to use dpq2. Do I need to clone the git repository with "git clone ?"[...]Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc
Oct 05 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:Maybe just Connection ?On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: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 ?On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote:No, you just dub add dpq2On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote:Say I want to use dpq2. Do I need to clone the git repository with "git clone ?"[...]Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc
Oct 05 2020
Just Connection worked. But how do I loop over results of a select statement. string sql=format(" SELECT * from %s ;",tablepredata); auto answer = conn.exec(sql); foreach(arow; answer){ writeln(arow); } Fails with, dub ~master: building configuration "application"... source/app.d(36,3): Error: invalid foreach aggregate answer, define opApply(), range primitives, or use .tupleof /usr/local/bin/ldc2 failed with exit code 1.
Oct 05 2020
On Monday, 5 October 2020 at 14:57:53 UTC, Alaindevos wrote:answer[0][0].as!PGtext contains good dataI found an answer.foreach(rownumber; answer.length.iota){ auto arow=answer[rownumber]; writeln(arow); }Yet it would be nice to know why i can't iterate directly over answer using foreach.
Oct 05 2020
On Monday, 5 October 2020 at 15:08:54 UTC, Alaindevos wrote:Looking at the implementation of the `Answer` type [1], I see no way to create a range or a slice, and no `opApply`. So you'll have to ask the maintainer about that. [1] https://github.com/denizzzka/dpq2/blob/master/src/dpq2/result.d#L107Yet it would be nice to know why i can't iterate directly over answer using foreach.
Oct 05 2020
On Monday, 5 October 2020 at 15:08:54 UTC, Alaindevos wrote:On Monday, 5 October 2020 at 14:57:53 UTC, Alaindevos wrote:Use "rangify" template to get forward range from answeranswer[0][0].as!PGtext contains good dataI found an answer.foreach(rownumber; answer.length.iota){ auto arow=answer[rownumber]; writeln(arow); }Yet it would be nice to know why i can't iterate directly over answer using foreach.
Oct 05 2020
Use "rangify" template to get forward range from answerThanks, this answers the question on programmatic level. Yet I guess something is special with the answer datatype which makes foreach to fail.
Oct 05 2020
On 10/5/20 11:42 AM, Alaindevos wrote:Instead of thinking of it as "foreach failing," instead consider that the library author did not implement foreach.Use "rangify" template to get forward range from answerThanks, this answers the question on programmatic level. Yet I guess something is special with the answer datatype which makes foreach to fail.
Oct 05 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:Is this the first time you are trying D?On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: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 ?[...]No, you just dub add dpq2
Oct 05 2020
On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn puremagic.com> wrote:Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong?Yes and no. Dub is Dlang dependency solution but it is not installer as pip isAs I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start.Yes if you want to use any of dub packages you need to add it as a dependency to your dub.json (dub.sdl)
Oct 05 2020
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: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 ?Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong?Yes and no. Dub is Dlang dependency solution but it is not installer as pip isAs I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start.Yes if you want to use any of dub packages you need to add it as a dependency to your dub.json (dub.sdl)
Oct 05 2020
On 10/5/20 12:05 PM, Alaindevos wrote:On Monday, 5 October 2020 at 08:54:39 UTC, Daniel Kozak wrote:Take a look at https://code.dlang.org/packages/dpq2 This is how packages work in D To add dpq2 dependency to your project you need to execute the command: ``` dub add dpq2 ``` it adds the last version of the dpq2 package. After this you are able to use this package in your project just import it in your source files.On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn puremagic.com> wrote: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 ?Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong?Yes and no. Dub is Dlang dependency solution but it is not installer as pip isAs I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start.Yes if you want to use any of dub packages you need to add it as a dependency to your dub.json (dub.sdl)
Oct 05 2020
On Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote: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 ?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. In your project root directory (where your dub.json/sdl is located), you should be able to run `dub add dpq2` and dub will add the dependency to your configuration. Or you can add it manually. For dub.json: "dependencies": { "dpq2": "~>1.0.17" } For dub.sdl: dependency "dpq2" version="~>1.0.17" Make sure libpq is installed on your system and you should be good to go. See: https://code.dlang.org/packages/dpq2 https://dub.pm/package-format-json https://dub.pm/package-format-sdl If you aren't using dub to build your project, then you could potentially use `dub install dpq2` and it will install it in a cache folder which, IIRC, should be in ~/.dub. However, I would use `git clone` or `dub fetch` so that you can keep it in a specific folder. I have some instructions for using my old Derelict packages when you aren't using dub for your project. You can adapt that to dpq2: http://derelictorg.github.io/building/without-dub/ Once you've pulled down dpq2, you'll need to build it, then when building your project you'll have to pass the dpq source path to the compiler (with the -Ipath) so it can find the imports, the path to the dpq library you built (with -L-Lpath), and the dpq library (-L-ldpq).
Oct 05 2020
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: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.[...]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. [...]
Oct 05 2020
On 10/5/20 6:01 AM, Alaindevos wrote:On Monday, 5 October 2020 at 09:24:33 UTC, Mike Parker wrote: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). -SteveOn Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote: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.[...]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. [...]
Oct 05 2020
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:It seems the D ecosystem is not immediately obvious to some people. Dub, compilers, and IDEs are recurring issues.On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn puremagic.com> wrote: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 ?[...]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)
Oct 07 2020
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
Oct 07 2020
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)
Oct 08 2020
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.
Oct 08 2020