Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #225352

Re: FOSS equivalents of *OLD* database and spreadsheet tools?

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups linux.debian.user
Subject Re: FOSS equivalents of *OLD* database and spreadsheet tools?
Date 2020-07-27 17:40 +0200
Message-ID <Axdol-7Sw-7@gated-at.bofh.it> (permalink)
References <Awwjn-6S3-1@gated-at.bofh.it> <AwxyN-7xo-1@gated-at.bofh.it> <Axa77-5X1-7@gated-at.bofh.it> <Axd50-7M3-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jul 27, 2020 at 11:16:45AM -0400, Michael Stone wrote:
> On Mon, Jul 27, 2020 at 08:09:36AM -0400, Greg Wooledge wrote:
> > For a project of this size and scope, a Tcl application with an sqlite3
> > database in a local file seems well suited.
> 
> Only on the internet can someone ask a simple question and get tcl as the
> answer. :-/

OK, here's a quick program to show how it might be done.  The interface
is quite primitive, but it's a proof of concept.

You need to install the libsqlite3-tcl package, if you're using Debian's
version of Tcl.  If you compile Tcl from upstream source, this package
is included by default.

Here's the program:

=========================================================
#!/usr/bin/tclsh8.6
package require sqlite3
set dbfile ./food.db

proc usage {} {
    global argv0
    puts stderr "usage: $argv0 {add|print|dump} arguments"
    exit 1
}

if {[file exists $dbfile]} {
    sqlite3 db $dbfile
} else {
    sqlite3 db $dbfile
    db eval {create table food (name text, calories real)}
}

lassign $argv cmd food cals
switch -- $cmd {
    add {
	if {[llength $argv] != 3} {usage}
	db eval {insert into food(name, calories) values (:food, :cals)}
    }
    print {
	if {[llength $argv] != 2} {usage}
	db eval {select calories from food where name = :food} v {}
	if {! [info exists v(calories)]} {
	    puts stderr "Food '$food' not found"
	    exit 1
	}
	puts $v(calories)
    }
    dump {
	db eval {select name, calories from food order by name} v {
	    puts [format "%-30.30s %f" $v(name) $v(calories)]
	}
    }
    default {usage}
}
=========================================================

And running it:

unicorn:~$ ./foo
usage: ./foo {add|print|dump} arguments
unicorn:~$ ./foo add pretzels 50
unicorn:~$ ./foo add corn 30
unicorn:~$ ./foo print corn
30.0
unicorn:~$ ./foo print 'potato chips'
Food 'potato chips' not found
unicorn:~$ ./foo dump
corn                           30.000000
pretzels                       50.000000
unicorn:~$ ls -l food.db
-rw-r--r-- 1 greg greg 8192 Jul 27 11:31 food.db
unicorn:~$ ./foo add corn 35
unicorn:~$ ./foo dump
corn                           30.000000
corn                           35.000000
pretzels                       50.000000

Oops.  Looks like we should consider making the name a unique index.
Well, you can add that to your version.

Do you consider this "difficult"?  If so, you are probably approaching
this problem as a non-programmer, in which case I don't know what to
tell you.  Programming languages exist for a reason, and Tcl is one of
the easiest ones for this particular job.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

FOSS equivalents of *OLD* database and spreadsheet tools? Richard Owlett <rowlett@cloud85.net> - 2020-07-25 19:40 +0200
  Re: FOSS equivalents of *OLD* database and spreadsheet tools? Paul M Foster <paulf@quillandmouse.com> - 2020-07-25 21:00 +0200
    Re: FOSS equivalents of *OLD* database and spreadsheet tools? David Wright <deblis@lionunicorn.co.uk> - 2020-07-25 21:50 +0200
    Re: FOSS equivalents of *OLD* database and spreadsheet tools? Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-27 14:10 +0200
      Re: FOSS equivalents of *OLD* database and spreadsheet tools? Michael Stone <mstone@debian.org> - 2020-07-27 17:20 +0200
        Re: FOSS equivalents of *OLD* database and spreadsheet tools? Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-27 17:40 +0200
          Re: FOSS equivalents of *OLD* database and spreadsheet tools? Michael Stone <mstone@debian.org> - 2020-07-27 21:50 +0200
            Re: FOSS equivalents of *OLD* database and spreadsheet tools? <tomas@tuxteam.de> - 2020-07-27 22:00 +0200
              Re: FOSS equivalents of *OLD* database and spreadsheet tools? Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-27 22:10 +0200
              Re: FOSS equivalents of *OLD* database and spreadsheet tools? Michael Stone <mstone@debian.org> - 2020-07-27 22:10 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? <tomas@tuxteam.de> - 2020-07-27 22:30 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-27 23:50 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-27 23:40 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? Michael Stone <mstone@debian.org> - 2020-07-27 23:50 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-27 23:50 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? mick crane <mick.crane@gmail.com> - 2020-07-28 09:00 +0200
            Re: FOSS equivalents of *OLD* database and spreadsheet tools? David Wright <deblis@lionunicorn.co.uk> - 2020-07-28 00:30 +0200
              Re: FOSS equivalents of *OLD* database and spreadsheet tools? rhkramer@gmail.com - 2020-07-28 04:00 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? Nicholas Geovanis <nickgeovanis@gmail.com> - 2020-07-28 05:00 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? Nicholas Geovanis <nickgeovanis@gmail.com> - 2020-07-28 05:10 +0200
                Re: FOSS equivalents of *OLD* database and spreadsheet tools? Miles Fidelman <mfidelman@meetinghouse.net> - 2020-07-28 09:20 +0200
        Re: FOSS equivalents of *OLD* database and spreadsheet tools? David Wright <deblis@lionunicorn.co.uk> - 2020-07-27 17:50 +0200
        Re: FOSS equivalents of *OLD* database and spreadsheet tools? <tomas@tuxteam.de> - 2020-07-27 18:10 +0200
        Re: FOSS equivalents of *OLD* database and spreadsheet tools? Miles Fidelman <mfidelman@meetinghouse.net> - 2020-07-27 18:40 +0200
  Re: FOSS equivalents of *OLD* database and spreadsheet tools? <tomas@tuxteam.de> - 2020-07-25 21:10 +0200
    Re: FOSS equivalents of *OLD* database and spreadsheet tools? Miles Fidelman <mfidelman@meetinghouse.net> - 2020-07-25 21:30 +0200
  Re: FOSS equivalents of *OLD* database and spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-25 22:30 +0200
    Re: FOSS equivalents of *OLD* database and spreadsheet tools? David Christensen <dpchrist@holgerdanske.com> - 2020-07-26 00:00 +0200
      Re: FOSS equivalents of *OLD* database and spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-26 10:00 +0200
        Re: FOSS equivalents of *OLD* database and spreadsheet tools? mick crane <mick.crane@gmail.com> - 2020-07-26 12:10 +0200
          Re: FOSS equivalents of *OLD* database and spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-26 15:30 +0200
          Re: FOSS equivalents of *OLD* database and spreadsheet tools? David Christensen <dpchrist@holgerdanske.com> - 2020-07-27 09:10 +0200
  Re: FOSS equivalents of *OLD* database and spreadsheet tools? David Christensen <dpchrist@holgerdanske.com> - 2020-07-25 22:30 +0200
  Re: FOSS equivalents of *OLD* database and spreadsheet tools? rhkramer@gmail.com - 2020-07-25 23:00 +0200
  Re: FOSS equivalents of *OLD* database and spreadsheet tools? Michael Stone <mstone@debian.org> - 2020-07-26 16:30 +0200
    Re: FOSS equivalents of *OLD* database and spreadsheet tools? <tomas@tuxteam.de> - 2020-07-26 16:50 +0200
    Re: FOSS equivalents of *OLD* database and spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-26 20:00 +0200
      Re: FOSS equivalents of *OLD* database and spreadsheet tools? Michael Stone <mstone@debian.org> - 2020-07-26 20:20 +0200
  Re: FOSS equivalents of *OLD* database and spreadsheet tools? Ajith R <ajithramayyan@yahoo.co.in> - 2020-07-27 16:20 +0200
  Re: FOSS equivalents of *OLD* database and spreadsheet tools? Eric S Fraga <e.fraga@ucl.ac.uk> - 2020-07-27 17:20 +0200
    [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? Richard Owlett <rowlett@cloud85.net> - 2020-07-29 11:50 +0200
      Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? mick crane <mick.crane@gmail.com> - 2020-07-29 12:20 +0200
      Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-29 13:20 +0200
        Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? Richard Owlett <rowlett@cloud85.net> - 2020-07-29 14:10 +0200
          Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? David Christensen <dpchrist@holgerdanske.com> - 2020-07-29 22:10 +0200
            Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? <tomas@tuxteam.de> - 2020-07-30 11:40 +0200
          Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? Tom Dial <tddial@comcast.net> - 2020-07-30 22:20 +0200
      Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and spreadsheet tools? Eric S Fraga <e.fraga@ucl.ac.uk> - 2020-07-30 11:30 +0200
        Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? Richard Owlett <rowlett@cloud85.net> - 2020-07-30 13:20 +0200
          Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and spreadsheet tools? Eric S Fraga <e.fraga@ucl.ac.uk> - 2020-07-30 16:20 +0200
        Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? Miles Fidelman <mfidelman@meetinghouse.net> - 2020-07-30 17:00 +0200
          Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? Richard Owlett <rowlett@cloud85.net> - 2020-07-30 17:10 +0200
          Re: [Interim Solution] Re: FOSS equivalents of *OLD* database and  spreadsheet tools? Joe <joe@jretrading.com> - 2020-07-30 19:40 +0200
    Re: FOSS equivalents of *OLD* database and spreadsheet tools? Richard Owlett <rowlett@cloud85.net> - 2020-07-30 14:50 +0200
      Re: FOSS equivalents of *OLD* database and spreadsheet          tools? Linux-Fan <Ma_Sys.ma@web.de> - 2020-07-30 15:10 +0200
        Re: FOSS equivalents of *OLD* database and spreadsheet tools? Richard Owlett <rowlett@cloud85.net> - 2020-07-30 16:10 +0200
    Example(s) of recutils project flow? - was [FOSS equivalents of *OLD*  database and spreadsheet tools?] Richard Owlett <rowlett@cloud85.net> - 2020-08-07 13:40 +0200
      Re: Example(s) of recutils project flow? - was [FOSS equivalents of  *OLD* database and spreadsheet tools?] David <bouncingcats@gmail.com> - 2020-08-07 13:50 +0200
        Re: Example(s) of recutils project flow? - was [FOSS equivalents of  *OLD* database and spreadsheet tools?] Richard Owlett <rowlett@cloud85.net> - 2020-08-07 14:40 +0200
          Re: Example(s) of recutils project flow? - was [FOSS equivalents of  *OLD* database and spreadsheet tools?] Andrei POPESCU <andreimpopescu@gmail.com> - 2020-08-11 12:30 +0200

csiph-web