Simple database: Difference between revisions

Content added Content deleted
(Added PicoLisp)
m (Formatting)
Line 8: Line 8:


You should track the following details:
You should track the following details:
* A description of the item. (eg title, name)
* A description of the item. (e.g., title, name)
* A category or tag (genre, topic, relationship (friend, family))
* A category or tag (genre, topic, relationship such as “friend” or “family”)
* A date (either the date when the entry was made or some other date that is meaningful (like the birthday)) (the date may be generated or entered manually)
* A date (either the date when the entry was made or some other date that is meaningful, like the birthday); the date may be generated or entered manually
* Other optional fields
* Other optional fields


Line 19: Line 19:
* Print all entries sorted by a date
* Print all entries sorted by a date


The category may be realized as a tag or as structure (making all entries in that category subitems)
The category may be realized as a tag or as structure (by making all entries in that category subitems)


The fileformat on disk should be human readable, but it need not be standardized. A natively available format that doesn't need an external library is preferred. Avoid developing your own format however if you can use an already existing one. If there is no existing format available pick one of: [[JSON]], [[S-Expressions]], [[YAML]], or [[wp:Comparison_of_data_serialization_formats|others]].
The file format on disk should be human readable, but it need not be standardized. A natively available format that doesn't need an external library is preferred. Avoid developing your own format however if you can use an already existing one. If there is no existing format available pick one of: [[JSON]], [[S-Expressions]], [[YAML]], or [[wp:Comparison_of_data_serialization_formats|others]].


See also [[Take notes on the command line]] for a related task.
See also [[Take notes on the command line]] for a related task.

=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
A tool to track the episodes you have watched in a series.
Tested with [[SBCL]] but should work with other implementations.


Run from the commandline as:
a tool to track the episodes you have watched in a series.
tested with [[SBCL]] but should work with other implementations.

run from the commandline as:
sbcl --script watch.lisp
sbcl --script watch.lisp


without arguments the function <code>(watch-list)</code> is invoked to show the last episode of each series.
Without arguments the function <code>(watch-list)</code> is invoked to show the last episode of each series.
with the argument <code>add</code> the function <code>(watch-add)</code> will allow you to add a new episode with series name, episode title, episode number and date watched. if the series does not yet exist you will be asked if you want to create it.
With the argument <code>add</code> the function <code>(watch-add)</code> will allow you to add a new episode with series name, episode title, episode number and date watched. If the series does not yet exist, you will be asked if you want to create it.

this code is also available under the GNU GPLv3.


This code is also available under the GNU GPLv3.
<lang lisp>(defvar db nil)
<lang lisp>(defvar db nil)


Line 231: Line 230:


=={{header|Pike}}==
=={{header|Pike}}==
{{trans|Common Lisp}}
an almost direct translation from common lisp:
<lang Pike>mapping db = ([]);
<lang Pike>mapping db = ([]);


Line 388: Line 387:


=={{header|Ruby}}==
=={{header|Ruby}}==

<lang ruby>require 'date'
<lang ruby>require 'date'
require 'json'
require 'json'