unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* guile-dbi from guix not working
@ 2022-05-07 11:26 Zelphir Kaltstahl
  2022-05-07 18:44 ` Luis Felipe
  2022-05-25 19:18 ` Arun Isaac
  0 siblings, 2 replies; 10+ messages in thread
From: Zelphir Kaltstahl @ 2022-05-07 11:26 UTC (permalink / raw)
  To: help-guix

Hi!

I have repeatedly tried to use guile-dbi from Guix at different commits and 
failed. I have the following setup for using guile-dbi:

channels.scm:

~~~~
(list (channel
         (name 'guix)
         (url"https://git.savannah.gnu.org/git/guix.git")
         (branch "master")
         (commit
           "02182c623e0b19f23701d9feaae096e5a1bd5823")
         (introduction
           (make-channel-introduction
             "9edb3f66fd807b096b48283debdcddccfea34bad"
             (openpgp-fingerprint
               "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))
~~~~

manifest.scm:

~~~~
(specifications->manifest
  '("guile@3.0.8"
    "guile-dbi"))
~~~~

guix shell:

~~~~
guix time-machine --channels="channels.scm" -- \
      shell --cores=8 --check --manifest="manifest.scm"
~~~~

guile code "example.scm" (mostly copied from the tutorial at 
https://htmlpreview.github.io/?https://github.com/opencog/guile-dbi/blob/master/website/guile-dbi.html):

~~~~
(import (dbi dbi))

;; Log into the database.
(define db-obj (dbi-open "sqlite3" "database"))
(display db-obj) (newline)

;; Create a table.
(dbi-query db-obj "create table hellotable(id int, name varchar(15))")

;; Look at the return status of the last SQL command
(display db-obj) (newline)

;; Populate the table with values.
(dbi-query db-obj "insert into hellotable ('id', 'name') values('33', 'ola')")
(dbi-query db-obj "insert into hellotable ('id', 'name') values('34', 'dzien dobre')")
(dbi-query db-obj "insert into hellotable ('id', 'name') values('44', 'annyong haseyo')")
(display db-obj) (newline)

;; Display each of the rows of the table, in turn.
(dbi-query db-obj "select * from hellotable")
(display db-obj) (newline)
(write (dbi-get_row db-obj)) (newline)
(write (dbi-get_row db-obj)) (newline)
(write (dbi-get_row db-obj)) (newline)
(write (dbi-get_row db-obj)) (newline)

;; Close the database.
(dbi-close db-obj)
(display db-obj) (newline)
~~~~

result:

~~~~
$ guile example.scm
#<guile-dbi close sqlite3 database (1 . file not found)>
#<guile-dbi close sqlite3 database (1 . invalid module handle)>
#<guile-dbi close sqlite3 database (1 . invalid module handle)>
#<guile-dbi close sqlite3 database (1 . invalid module handle)>
()
()
()
()
#<guile-dbi close sqlite3 database (1 . invalid module handle)>
~~~~

It does not seem to matter, whether I give it an absolute filename for the 
database. Still file not found.

Is it really broken, or am I doing something wrong?

Best regards,
Zelphir

-- 
repositories:https://notabug.org/ZelphirKaltstahl

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: guile-dbi from guix not working
  2022-05-07 11:26 guile-dbi from guix not working Zelphir Kaltstahl
@ 2022-05-07 18:44 ` Luis Felipe
  2022-05-08 12:33   ` Zelphir Kaltstahl
  2022-05-25 19:18 ` Arun Isaac
  1 sibling, 1 reply; 10+ messages in thread
From: Luis Felipe @ 2022-05-07 18:44 UTC (permalink / raw)
  To: Zelphir Kaltstahl; +Cc: help-guix


[-- Attachment #1.1: Type: text/plain, Size: 1391 bytes --]

Hi Zelphir,

On Saturday, May 7th, 2022 at 11:26 AM, Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> wrote:

> Is it really broken, or am I doing something wrong?

For what it's worth, it fails in the same way for me too. Trying to open a connection results in a handle with "file not found" status.

If you just need to work with SQLite databases, I tried guile-sqlite3 and it worked (connecting, inserting records, etc). It is not documented, but the tests help discover how to use some things (https://notabug.org/guile-sqlite3/guile-sqlite3.git).

For example, I don't know what I'm doing, but this works:

~~~
(import (sqlite3))

;; Log into the database.
(define db (sqlite-open "database.sqlite3"))

;; Create a table.
(sqlite-exec db "create table hellotable(id int, name varchar(15))")

;; Populate the table with values.
(sqlite-exec db "insert into hellotable ('id', 'name') values('33', 'ola')")
(sqlite-exec db "insert into hellotable ('id', 'name') values('34', 'dzien dobre')")
(sqlite-exec db "insert into hellotable ('id', 'name') values('44', 'annyong haseyo')")

;; Display each of the rows of the table, in turn.
(let* [(stmt (sqlite-prepare db "select * from hellotable"))
       (result (sqlite-map identity stmt))]

  (for-each
   (lambda (row) (begin (display row) (newline)))
   result))

;; Close connection.
(sqlite-close db)
~~~

[-- Attachment #1.2: publickey - luis.felipe.la@protonmail.com - 0x12DE1598.asc --]
[-- Type: application/pgp-keys, Size: 1815 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 509 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: guile-dbi from guix not working
  2022-05-07 18:44 ` Luis Felipe
@ 2022-05-08 12:33   ` Zelphir Kaltstahl
  0 siblings, 0 replies; 10+ messages in thread
From: Zelphir Kaltstahl @ 2022-05-08 12:33 UTC (permalink / raw)
  To: Luis Felipe; +Cc: help-guix

Hello Luis!

On 5/7/22 20:44, Luis Felipe wrote:
> Hi Zelphir,
>
> On Saturday, May 7th, 2022 at 11:26 AM, Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> wrote:
>
>> Is it really broken, or am I doing something wrong?
> For what it's worth, it fails in the same way for me too. Trying to open a connection results in a handle with "file not found" status.
>
> If you just need to work with SQLite databases, I tried guile-sqlite3 and it worked (connecting, inserting records, etc). It is not documented, but the tests help discover how to use some things (https://notabug.org/guile-sqlite3/guile-sqlite3.git).
>
> For example, I don't know what I'm doing, but this works:
>
> ~~~
> (import (sqlite3))
>
> ;; Log into the database.
> (define db (sqlite-open "database.sqlite3"))
>
> ;; Create a table.
> (sqlite-exec db "create table hellotable(id int, name varchar(15))")
>
> ;; Populate the table with values.
> (sqlite-exec db "insert into hellotable ('id', 'name') values('33', 'ola')")
> (sqlite-exec db "insert into hellotable ('id', 'name') values('34', 'dzien dobre')")
> (sqlite-exec db "insert into hellotable ('id', 'name') values('44', 'annyong haseyo')")
>
> ;; Display each of the rows of the table, in turn.
> (let* [(stmt (sqlite-prepare db "select * from hellotable"))
>         (result (sqlite-map identity stmt))]
>
>    (for-each
>     (lambda (row) (begin (display row) (newline)))
>     result))
>
> ;; Close connection.
> (sqlite-close db)
> ~~~

This is exactly what I have done : )

I looked at the tests and changed the code a little: 
https://notabug.org/ZelphirKaltstahl/guile-examples/commit/a9e635b990f5384ccfb3613003489f47759ca690. 
However, I saw, that there are segfaults reported at 
https://notabug.org/guile-sqlite3/guile-sqlite3/issues/17 and also I realized, 
that on GNU Guix version 0.1.2 is available, while in the repo there is 0.1.3, 
which has trace functions (which I am not sure I will ever need). So I am a bit 
unsure, how solid of an option it really is.

Thanks for the idea nevertheless!

Best regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: guile-dbi from guix not working
  2022-05-07 11:26 guile-dbi from guix not working Zelphir Kaltstahl
  2022-05-07 18:44 ` Luis Felipe
@ 2022-05-25 19:18 ` Arun Isaac
  2022-05-28 16:37   ` Zelphir Kaltstahl
  1 sibling, 1 reply; 10+ messages in thread
From: Arun Isaac @ 2022-05-25 19:18 UTC (permalink / raw)
  To: Zelphir Kaltstahl, help-guix


Hi Zelphir,

> ~~~~
> (specifications->manifest
>   '("guile@3.0.8"
>     "guile-dbi"))
> ~~~~

I think you missed guile-dbd-sqlite3 in the manifest above. With
guile-dbd-sqlite3 added, it works for me. Here are my results.

--8<---------------cut here---------------start------------->8---
#<guile-dbi open sqlite3 database (0 . db connected)>
#<guile-dbi open sqlite3 database (1 . table hellotable already exists)>
#<guile-dbi open sqlite3 database (0 . query ok)>
#<guile-dbi open sqlite3 database (0 . query ok)>
(("id" . 33) ("name" . "ola"))
(("id" . 34) ("name" . "dzien dobre"))
(("id" . 44) ("name" . "annyong haseyo"))
(("id" . 33) ("name" . "ola"))
#<guile-dbi close sqlite3 database (0 . dbi closed)>
--8<---------------cut here---------------end--------------->8---

Hope that helps!
Arun


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: guile-dbi from guix not working
  2022-05-25 19:18 ` Arun Isaac
@ 2022-05-28 16:37   ` Zelphir Kaltstahl
  2022-05-29  7:57     ` Arun Isaac
  0 siblings, 1 reply; 10+ messages in thread
From: Zelphir Kaltstahl @ 2022-05-28 16:37 UTC (permalink / raw)
  To: Arun Isaac; +Cc: help-guix

On 5/25/22 21:18, Arun Isaac wrote:
> Hi Zelphir,
>
>> ~~~~
>> (specifications->manifest
>>    '("guile@3.0.8"
>>      "guile-dbi"))
>> ~~~~
> I think you missed guile-dbd-sqlite3 in the manifest above. With
> guile-dbd-sqlite3 added, it works for me. Here are my results.
>
> --8<---------------cut here---------------start------------->8---
> #<guile-dbi open sqlite3 database (0 . db connected)>
> #<guile-dbi open sqlite3 database (1 . table hellotable already exists)>
> #<guile-dbi open sqlite3 database (0 . query ok)>
> #<guile-dbi open sqlite3 database (0 . query ok)>
> (("id" . 33) ("name" . "ola"))
> (("id" . 34) ("name" . "dzien dobre"))
> (("id" . 44) ("name" . "annyong haseyo"))
> (("id" . 33) ("name" . "ola"))
> #<guile-dbi close sqlite3 database (0 . dbi closed)>
> --8<---------------cut here---------------end--------------->8---
>
> Hope that helps!
> Arun

Hi Arun!

Thanks, that solves it.
Should guile-dbd-sqlite3 not be a dependency of guile-dbi then? But on the other hand, what if one only wanted to interact with one database type and not the other? So maybe not a must have dependency then. Hm. What is the typical Guix solution for this kind of "specialization" of a library? I think in the Python world, in requirements files it would be something like `library[specialization] == version`, to install that variant.

Best regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: guile-dbi from guix not working
  2022-05-28 16:37   ` Zelphir Kaltstahl
@ 2022-05-29  7:57     ` Arun Isaac
  2022-05-29  8:58       ` non-input dependencies Was: " raingloom
  0 siblings, 1 reply; 10+ messages in thread
From: Arun Isaac @ 2022-05-29  7:57 UTC (permalink / raw)
  To: Zelphir Kaltstahl; +Cc: help-guix


Hi Zelphir,

> Should guile-dbd-sqlite3 not be a dependency of guile-dbi then? But on
> the other hand, what if one only wanted to interact with one database
> type and not the other? So maybe not a must have dependency
> then. Hm. What is the typical Guix solution for this kind of
> "specialization" of a library? I think in the Python world, in
> requirements files it would be something like `library[specialization]
> == version`, to install that variant.

You can think of guile-dbd-* as plugins for guile-dbi. So, you install
guile-dbi along with whatever plugins you want for guile-dbi. It's no
different from installing emacs and installing emacs packages of
interest. I don't think we need a special Guix feature for this.

But, guile-dbi should be fixed to produce a proper error message that a
required plugin is missing. It should not produce misleading error
messages like "file not found". If you're up for it, you can try
reporting this to guile-dbi upstream.

Cheers!
Arun


^ permalink raw reply	[flat|nested] 10+ messages in thread

* non-input dependencies Was: guile-dbi from guix not working
  2022-05-29  7:57     ` Arun Isaac
@ 2022-05-29  8:58       ` raingloom
  2022-05-29 14:42         ` Zelphir Kaltstahl
  0 siblings, 1 reply; 10+ messages in thread
From: raingloom @ 2022-05-29  8:58 UTC (permalink / raw)
  To: Arun Isaac; +Cc: Zelphir Kaltstahl, help-guix

On Sun, 29 May 2022 13:27:23 +0530
Arun Isaac <arunisaac@systemreboot.net> wrote:

> Hi Zelphir,
> 
> > Should guile-dbd-sqlite3 not be a dependency of guile-dbi then? But
> > on the other hand, what if one only wanted to interact with one
> > database type and not the other? So maybe not a must have dependency
> > then. Hm. What is the typical Guix solution for this kind of
> > "specialization" of a library? I think in the Python world, in
> > requirements files it would be something like
> > `library[specialization] == version`, to install that variant.  
> 
> You can think of guile-dbd-* as plugins for guile-dbi. So, you install
> guile-dbi along with whatever plugins you want for guile-dbi. It's no
> different from installing emacs and installing emacs packages of
> interest. I don't think we need a special Guix feature for this.
> 
> But, guile-dbi should be fixed to produce a proper error message that
> a required plugin is missing. It should not produce misleading error
> messages like "file not found". If you're up for it, you can try
> reporting this to guile-dbi upstream.
> 
> Cheers!
> Arun
> 

I disagree, Guix packages should make it clear when they have
non-input dependencies. Users should not be forced to play
dependency-whack-a-mole.
Run-time dependencies should either be listed in the package
description or in some extra field.
I absolutely hate it that I have to go look at bug trackers and
external docs to find out why a package I installed isn't working
correctly, especially when other package managers have already solved
this issue.
We don't have to do the exact same thing as them, but there has to be
some way for a user to know if, for example, they need ffmpeg in their
manifest if they want to use yt-dlp.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: non-input dependencies Was: guile-dbi from guix not working
  2022-05-29  8:58       ` non-input dependencies Was: " raingloom
@ 2022-05-29 14:42         ` Zelphir Kaltstahl
  2022-05-29 15:23           ` raingloom
  0 siblings, 1 reply; 10+ messages in thread
From: Zelphir Kaltstahl @ 2022-05-29 14:42 UTC (permalink / raw)
  To: raingloom, Arun Isaac; +Cc: help-guix

Hi!

On 5/29/22 10:58, raingloom wrote:
> On Sun, 29 May 2022 13:27:23 +0530
> Arun Isaac <arunisaac@systemreboot.net> wrote:
>
>> Hi Zelphir,
>>
>>> Should guile-dbd-sqlite3 not be a dependency of guile-dbi then? But
>>> on the other hand, what if one only wanted to interact with one
>>> database type and not the other? So maybe not a must have dependency
>>> then. Hm. What is the typical Guix solution for this kind of
>>> "specialization" of a library? I think in the Python world, in
>>> requirements files it would be something like
>>> `library[specialization] == version`, to install that variant.
>> You can think of guile-dbd-* as plugins for guile-dbi. So, you install
>> guile-dbi along with whatever plugins you want for guile-dbi. It's no
>> different from installing emacs and installing emacs packages of
>> interest. I don't think we need a special Guix feature for this.
>>
>> But, guile-dbi should be fixed to produce a proper error message that
>> a required plugin is missing. It should not produce misleading error
>> messages like "file not found". If you're up for it, you can try
>> reporting this to guile-dbi upstream.
>>
>> Cheers!
>> Arun
>>
> I disagree, Guix packages should make it clear when they have
> non-input dependencies. Users should not be forced to play
> dependency-whack-a-mole.
> Run-time dependencies should either be listed in the package
> description or in some extra field.
> I absolutely hate it that I have to go look at bug trackers and
> external docs to find out why a package I installed isn't working
> correctly, especially when other package managers have already solved
> this issue.
> We don't have to do the exact same thing as them, but there has to be
> some way for a user to know if, for example, they need ffmpeg in their
> manifest if they want to use yt-dlp.

I think I get both of your viewpoints. I did not think of the database specific 
packages as plugins, but it makes sense. However, it also makes sense, that you 
need at least one of them, to actually do anything with guile-dbi (as far as I 
know), so it is also not the case, that you could make much use of guile-dbi 
without any of those packages.

Maybe one solution could be having 1 general package acting like guile-dbi 
package is acting now, in terms of dependencies, and also having N packages, one 
for each guile-dbi + database specific combination, so that you can install a 
package that does take care of installing all things required for working with 
that specific database.

But maybe that would become too many packages in the future to keep track of and 
update accordingly. And also now I know what mistake I made and things work. But 
what about the next person? Is there some way, that there could be a hint, when 
installing guile-dbi, that you might need another package as well? And how often 
is there such a situation? Maybe creating a general solution is not worth it, or 
maybe it is.

Of course, the error message could be better, as it also directed me to tripple 
and quadruppel checking, that I am specifying the correct filename and that I am 
not insane.

Anyway, thanks for the help and the explanations all : )

Best regards,
Zelphir

-- 
repositories: https://notabug.org/ZelphirKaltstahl



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: non-input dependencies Was: guile-dbi from guix not working
  2022-05-29 14:42         ` Zelphir Kaltstahl
@ 2022-05-29 15:23           ` raingloom
  2022-05-30  6:31             ` Arun Isaac
  0 siblings, 1 reply; 10+ messages in thread
From: raingloom @ 2022-05-29 15:23 UTC (permalink / raw)
  To: Zelphir Kaltstahl; +Cc: Arun Isaac, help-guix

On Sun, 29 May 2022 14:42:32 +0000
Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> wrote:

> Hi!
> 
> On 5/29/22 10:58, raingloom wrote:
> > On Sun, 29 May 2022 13:27:23 +0530
> > Arun Isaac <arunisaac@systemreboot.net> wrote:
> >  
> >> Hi Zelphir,
> >>  
> >>> Should guile-dbd-sqlite3 not be a dependency of guile-dbi then?
> >>> But on the other hand, what if one only wanted to interact with
> >>> one database type and not the other? So maybe not a must have
> >>> dependency then. Hm. What is the typical Guix solution for this
> >>> kind of "specialization" of a library? I think in the Python
> >>> world, in requirements files it would be something like
> >>> `library[specialization] == version`, to install that variant.  
> >> You can think of guile-dbd-* as plugins for guile-dbi. So, you
> >> install guile-dbi along with whatever plugins you want for
> >> guile-dbi. It's no different from installing emacs and installing
> >> emacs packages of interest. I don't think we need a special Guix
> >> feature for this.
> >>
> >> But, guile-dbi should be fixed to produce a proper error message
> >> that a required plugin is missing. It should not produce
> >> misleading error messages like "file not found". If you're up for
> >> it, you can try reporting this to guile-dbi upstream.
> >>
> >> Cheers!
> >> Arun
> >>  
> > I disagree, Guix packages should make it clear when they have
> > non-input dependencies. Users should not be forced to play
> > dependency-whack-a-mole.
> > Run-time dependencies should either be listed in the package
> > description or in some extra field.
> > I absolutely hate it that I have to go look at bug trackers and
> > external docs to find out why a package I installed isn't working
> > correctly, especially when other package managers have already
> > solved this issue.
> > We don't have to do the exact same thing as them, but there has to
> > be some way for a user to know if, for example, they need ffmpeg in
> > their manifest if they want to use yt-dlp.  
> 
> I think I get both of your viewpoints. I did not think of the
> database specific packages as plugins, but it makes sense. However,
> it also makes sense, that you need at least one of them, to actually
> do anything with guile-dbi (as far as I know), so it is also not the
> case, that you could make much use of guile-dbi without any of those
> packages.
> 
> Maybe one solution could be having 1 general package acting like
> guile-dbi package is acting now, in terms of dependencies, and also
> having N packages, one for each guile-dbi + database specific
> combination, so that you can install a package that does take care of
> installing all things required for working with that specific
> database.
> 
> But maybe that would become too many packages in the future to keep
> track of and update accordingly. And also now I know what mistake I
> made and things work. But what about the next person? Is there some
> way, that there could be a hint, when installing guile-dbi, that you
> might need another package as well? And how often is there such a
> situation? Maybe creating a general solution is not worth it, or
> maybe it is.
> 
> Of course, the error message could be better, as it also directed me
> to tripple and quadruppel checking, that I am specifying the correct
> filename and that I am not insane.
> 
> Anyway, thanks for the help and the explanations all : )
> 
> Best regards,
> Zelphir
> 

IMHO as a first step we should just add this information to the package
descriptions. Simple, backwards compatible, doesn't restrict us, etc.
Eg.: for emacs-geiser, just add a line that says: "To use it with a
given Scheme dialect, install emacs-geiser-<scheme-dialect> in the
same environment."
Bam, no more confusion over why a package isn't doing anything.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: non-input dependencies Was: guile-dbi from guix not working
  2022-05-29 15:23           ` raingloom
@ 2022-05-30  6:31             ` Arun Isaac
  0 siblings, 0 replies; 10+ messages in thread
From: Arun Isaac @ 2022-05-30  6:31 UTC (permalink / raw)
  To: raingloom, Zelphir Kaltstahl; +Cc: help-guix


> IMHO as a first step we should just add this information to the package
> descriptions. Simple, backwards compatible, doesn't restrict us, etc.
> Eg.: for emacs-geiser, just add a line that says: "To use it with a
> given Scheme dialect, install emacs-geiser-<scheme-dialect> in the
> same environment."
> Bam, no more confusion over why a package isn't doing anything.

I agree with this fix. And, it seemed very easy. So, I started working
on it. But, when I try to change the guile-dbi package description,
`guix lint' complains that since guile-dbi is a GNU package, we should
prefer to keep the upstream description. Now, it seems like we should
change the upstream guile-dbi description to change the Guix package
description. Feels a little bureaucratic to me.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-05-30  6:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-07 11:26 guile-dbi from guix not working Zelphir Kaltstahl
2022-05-07 18:44 ` Luis Felipe
2022-05-08 12:33   ` Zelphir Kaltstahl
2022-05-25 19:18 ` Arun Isaac
2022-05-28 16:37   ` Zelphir Kaltstahl
2022-05-29  7:57     ` Arun Isaac
2022-05-29  8:58       ` non-input dependencies Was: " raingloom
2022-05-29 14:42         ` Zelphir Kaltstahl
2022-05-29 15:23           ` raingloom
2022-05-30  6:31             ` Arun Isaac

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).