Simple database: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: syntax coloured, marked p2js incompatible)
m (syntax highlighting fixup automation)
Line 41: Line 41:
{{trans|Kotlin}}
{{trans|Kotlin}}


<lang 11l>T Item
<syntaxhighlight lang="11l">T Item
String name, date, category
String name, date, category


Line 119: Line 119:
printUsage()
printUsage()
E
E
printUsage()</lang>
printUsage()</syntaxhighlight>


{{out}}
{{out}}
Line 126: Line 126:
=={{header|Bracmat}}==
=={{header|Bracmat}}==
This is a rather minimal solution. The program is run from the command line of the operating system, in this example the Windows command prompt. The program is stored in a file called 'sdb':
This is a rather minimal solution. The program is run from the command line of the operating system, in this example the Windows command prompt. The program is stored in a file called 'sdb':
<lang bracmat> whl
<syntaxhighlight lang="bracmat"> whl
' ( arg$:?command
' ( arg$:?command
& ( get'db
& ( get'db
Line 205: Line 205:
)
)
);
);
</syntaxhighlight>
</lang>
First we add some records, a some ships that arrived at the harbour in Rotterdam today.
First we add some records, a some ships that arrived at the harbour in Rotterdam today.
<pre>bracmat "get$sdb" add name "CORONA BULKER" tag "BULK CARRIER" date "2014.10.21.04:00"
<pre>bracmat "get$sdb" add name "CORONA BULKER" tag "BULK CARRIER" date "2014.10.21.04:00"
Line 258: Line 258:
"Treasure Beach","Argus","Jemky","09-22-1999","Lancast"
"Treasure Beach","Argus","Jemky","09-22-1999","Lancast"


<lang C>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h> /* malloc */
#include <stdlib.h> /* malloc */
#include <string.h> /* strlen */
#include <string.h> /* strlen */
Line 450: Line 450:
}
}
else return ((*p1)->date > (*p2)->date);
else return ((*p1)->date > (*p2)->date);
}</lang>
}</syntaxhighlight>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
<lang C sharp>
<syntaxhighlight lang="c sharp">
using System;
using System;
using System.IO;
using System.IO;
Line 777: Line 777:
}
}
}
}
</syntaxhighlight>
</lang>
{{out| Program Input and Output}}
{{out| Program Input and Output}}
<pre>
<pre>
Line 815: Line 815:
This is a souped-up version of the task from [[Take notes on the command line]]. It stores the current date, a tag, a title and a note as an entry in a file. The database produced is not particularly human-readable or easy to modify, but it is in a well-structured format.
This is a souped-up version of the task from [[Take notes on the command line]]. It stores the current date, a tag, a title and a note as an entry in a file. The database produced is not particularly human-readable or easy to modify, but it is in a well-structured format.
{{works with|OpenCOBOL}}
{{works with|OpenCOBOL}}
<lang cobol> IDENTIFICATION DIVISION.
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. simple-database.
PROGRAM-ID. simple-database.


Line 1,076: Line 1,076:
"The title should be specified as shown for -c."
"The title should be specified as shown for -c."
DISPLAY " -t - Show all the entries sorted by tag."
DISPLAY " -t - Show all the entries sorted by tag."
.</lang>
.</syntaxhighlight>


Sample session:
Sample session:
Line 1,115: Line 1,115:
Tested with [[Common Lisp]]. ''(Save the code below as db.lisp)''
Tested with [[Common Lisp]]. ''(Save the code below as db.lisp)''


<lang lisp>(defvar *db* nil)
<syntaxhighlight lang="lisp">(defvar *db* nil)


(defvar *db-cat* (make-hash-table :test 'equal))
(defvar *db-cat* (make-hash-table :test 'equal))
Line 1,232: Line 1,232:
nil))
nil))


(db-cmd-run (db-argv))</lang>
(db-cmd-run (db-argv))</syntaxhighlight>




Line 1,282: Line 1,282:


=={{header|D}}==
=={{header|D}}==
<lang d>import std.stdio, std.algorithm, std.string, std.conv, std.array,
<syntaxhighlight lang="d">import std.stdio, std.algorithm, std.string, std.conv, std.array,
std.file, std.csv, std.datetime;
std.file, std.csv, std.datetime;


Line 1,368: Line 1,368:
default: printUsage(); break;
default: printUsage(); break;
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>C:\>simdb add item1 cat1
<pre>C:\>simdb add item1 cat1
Line 1,419: Line 1,419:


=={{header|Erlang}}==
=={{header|Erlang}}==
<syntaxhighlight lang="erlang">
<lang Erlang>
#! /usr/bin/env escript
#! /usr/bin/env escript


Line 1,474: Line 1,474:
io:fwrite( "Data stored in ~p~n", [file()] ),
io:fwrite( "Data stored in ~p~n", [file()] ),
init:stop().
init:stop().
</syntaxhighlight>
</lang>
Command line session started with these file contents as database:
Command line session started with these file contents as database:
<pre>
<pre>
Line 1,573: Line 1,573:


Code:
Code:
<lang forth>\ sdb.fs Simple database. Gforth 0.7.0 specific
<syntaxhighlight lang="forth">\ sdb.fs Simple database. Gforth 0.7.0 specific
' noop is bootmessage
' noop is bootmessage


Line 1,701: Line 1,701:
cr cr ;
cr cr ;
current !
current !
SEAL godb</lang>
SEAL godb</syntaxhighlight>


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 2,043: Line 2,043:
fmt.Println(err)
fmt.Println(err)
}
}
}</lang>
}</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
Line 2,051: Line 2,051:
Item {description = "La traviata", category = ["Classical"], date = Date 2012 10 19, optional = ["Giuseppe Verdi","1853"]}
Item {description = "La traviata", category = ["Classical"], date = Date 2012 10 19, optional = ["Giuseppe Verdi","1853"]}


<lang Haskell>import Control.Monad.State
<syntaxhighlight lang="haskell">import Control.Monad.State
import Data.List (sortBy, nub)
import Data.List (sortBy, nub)
import System.Environment (getArgs, getProgName)
import System.Environment (getArgs, getProgName)
Line 2,179: Line 2,179:
mapM_ (hPutStrLn hw . show) v
mapM_ (hPutStrLn hw . show) v
hClose hw
hClose hw
</syntaxhighlight>
</lang>


=={{header|J}}==
=={{header|J}}==
Line 2,185: Line 2,185:
J comes with a sql database, jdb. Jdb's columns are memory mapped files with header information. These won't meet the human readable data file requirement. Hence, this program:
J comes with a sql database, jdb. Jdb's columns are memory mapped files with header information. These won't meet the human readable data file requirement. Hence, this program:


<lang j>HELP=: 0 :0
<syntaxhighlight lang="j">HELP=: 0 :0
Commands:
Commands:


Line 2,293: Line 2,293:


exit 0
exit 0
</syntaxhighlight>
</lang>
Assume the j code is stored in file s . These bash commands, stored in file input , create a database using add .
Assume the j code is stored in file s . These bash commands, stored in file input , create a database using add .
<lang sh>D='jconsole s dataflow'
<syntaxhighlight lang="sh">D='jconsole s dataflow'
$D add name expression algebraic rank valence example explanation
$D add name expression algebraic rank valence example explanation
Line 2,308: Line 2,308:
$D add atop 'x f@g y' 'f(g(x,y))' 'rank of g' dyad '>@{.' '(lisp) open the car'
$D add atop 'x f@g y' 'f(g(x,y))' 'rank of g' dyad '>@{.' '(lisp) open the car'
$D add 'many more!'
$D add 'many more!'
</syntaxhighlight>
</lang>
Now we look up data from the bash command line.
Now we look up data from the bash command line.
<syntaxhighlight lang="sh">
<lang sh>
$ . input # source the input
$ . input # source the input
$ echo $D
$ echo $D
Line 2,386: Line 2,386:
'2012-02-08:23:45:06.515';'atop';'x f@g y';'f(g(x,y))';'rank of g';'dyad';'>@{.';'(lisp) open the car'
'2012-02-08:23:45:06.515';'atop';'x f@g y';'f(g(x,y))';'rank of g';'dyad';'>@{.';'(lisp) open the car'
'2012-02-08:23:45:06.539';'many more!'
'2012-02-08:23:45:06.539';'many more!'
$ </lang>
$ </syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
{{trans|D}}
{{trans|D}}
{{works with|Java|7}}
{{works with|Java|7}}
<lang java>import java.io.*;
<syntaxhighlight lang="java">import java.io.*;
import java.text.*;
import java.text.*;
import java.util.*;
import java.util.*;
Line 2,515: Line 2,515:
+ "\"some category name\"");
+ "\"some category name\"");
}
}
}</lang>
}</syntaxhighlight>


Output:
Output:
Line 2,559: Line 2,559:
Sandy Allen,2002-03-09,Colorado,friend,sandya@mail.com
Sandy Allen,2002-03-09,Colorado,friend,sandya@mail.com
Fred Kobo,1967-10-10,Colorado,friend,fkobo@example.net</pre>
Fred Kobo,1967-10-10,Colorado,friend,fkobo@example.net</pre>
<lang julia>using CSV, DataFrames, ArgParse, Dates
<syntaxhighlight lang="julia">using CSV, DataFrames, ArgParse, Dates


setting = ArgParseSettings()
setting = ArgParseSettings()
Line 2,619: Line 2,619:
println("Changes written to file $filename.")
println("Changes written to file $filename.")
end
end
</syntaxhighlight>
</lang>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|Java}}
{{trans|Java}}
... though not quite the same.
... though not quite the same.
<lang scala>// version 1.2.31
<syntaxhighlight lang="scala">// version 1.2.31


import java.text.SimpleDateFormat
import java.text.SimpleDateFormat
Line 2,733: Line 2,733:
else -> printUsage()
else -> printUsage()
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 2,762: Line 2,762:
There are some important differences with D version and Kotlin versions. Firstly, the way to manage the command arguments is somewhat different. And secondly, the database is stored in JSON format rather than in CSV format. Indeed, if Nim provides a parser of CSV files, it provides better support for JSON with procedures for serialization of Nim objects to JSON and deserialization from JSON to Nim objects. This can be seen in the following program.
There are some important differences with D version and Kotlin versions. Firstly, the way to manage the command arguments is somewhat different. And secondly, the database is stored in JSON format rather than in CSV format. Indeed, if Nim provides a parser of CSV files, it provides better support for JSON with procedures for serialization of Nim objects to JSON and deserialization from JSON to Nim objects. This can be seen in the following program.


<lang Nim>import algorithm, json, os, strformat, strutils, times
<syntaxhighlight lang="nim">import algorithm, json, os, strformat, strutils, times


const FileName = "simdb.json"
const FileName = "simdb.json"
Line 2,862: Line 2,862:
of "all":
of "all":
if params.len != 0: printUsage()
if params.len != 0: printUsage()
printAll()</lang>
printAll()</syntaxhighlight>


{{out}}
{{out}}
Line 2,885: Line 2,885:


=={{header|Perl}}==
=={{header|Perl}}==
<lang Perl>#!/usr/bin/perl
<syntaxhighlight lang="perl">#!/usr/bin/perl
use warnings;
use warnings;
use strict;
use strict;
Line 3,002: Line 3,002:
if $by_date;
if $by_date;
}
}
}</lang>
}</syntaxhighlight>
Sample session<pre> ~ $ db.pl n 'Donald Trump' Republican 2017-01-20
Sample session<pre> ~ $ db.pl n 'Donald Trump' Republican 2017-01-20
~ $ db.pl n 'Barack Obama' Democratic 2009-01-20
~ $ db.pl n 'Barack Obama' Democratic 2009-01-20
Line 3,021: Line 3,021:


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(notonline)-->
<!--<syntaxhighlight lang="phix">(notonline)-->
<span style="color: #000080;font-style:italic;">--
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Simple_db.exw
-- demo\rosetta\Simple_db.exw
Line 3,121: Line 3,121:
<span style="color: #000000;">process</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cl</span><span style="color: #0000FF;">[</span><span style="color: #000000;">3</span><span style="color: #0000FF;">..$])</span>
<span style="color: #000000;">process</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cl</span><span style="color: #0000FF;">[</span><span style="color: #000000;">3</span><span style="color: #0000FF;">..$])</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
Sample session
Sample session
<pre>
<pre>
Line 3,152: Line 3,152:
=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
The '[http://software-lab.de/doc/refR.html#rc rc]' resource file handling function is used typically for such tasks. It also takes care of proper locking and protection.
The '[http://software-lab.de/doc/refR.html#rc rc]' resource file handling function is used typically for such tasks. It also takes care of proper locking and protection.
<lang PicoLisp>#!/usr/bin/pil
<syntaxhighlight lang="picolisp">#!/usr/bin/pil


(de usage ()
(de usage ()
Line 3,187: Line 3,187:
(T (usage)) ) )
(T (usage)) ) )


(bye)</lang>
(bye)</syntaxhighlight>
Test:
Test:
<pre>$ sdb CDs add "Title 1" "Category 1" 2011-11-13
<pre>$ sdb CDs add "Title 1" "Category 1" 2011-11-13
Line 3,212: Line 3,212:
=={{header|Pike}}==
=={{header|Pike}}==
{{trans|Common Lisp}} (simplified)
{{trans|Common Lisp}} (simplified)
<lang Pike>mapping db = ([]);
<syntaxhighlight lang="pike">mapping db = ([]);


mapping make_episode(string series, string title, string episode, array date)
mapping make_episode(string series, string title, string episode, array date)
Line 3,365: Line 3,365:
else
else
watch_list(db);
watch_list(db);
}</lang>
}</syntaxhighlight>


=={{header|PowerShell}}==
=={{header|PowerShell}}==
<syntaxhighlight lang="powershell">
<lang PowerShell>
function db
function db
{
{
Line 3,450: Line 3,450:
db -Name Vince -Category family -Birthday 3/10/1960
db -Name Vince -Category family -Birthday 3/10/1960
db -Name Wayne -Category coworker -Birthday 5/29/1962
db -Name Wayne -Category coworker -Birthday 5/29/1962
</syntaxhighlight>
</lang>
Here is the data from the CSV file as a PowerShell Object:
Here is the data from the CSV file as a PowerShell Object:
<syntaxhighlight lang="powershell">
<lang PowerShell>
db
db
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
Line 3,467: Line 3,467:
</pre>
</pre>
The latest entry:
The latest entry:
<syntaxhighlight lang="powershell">
<lang PowerShell>
db -Latest
db -Latest
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
Line 3,477: Line 3,477:
</pre>
</pre>
The latest entries by category:
The latest entries by category:
<syntaxhighlight lang="powershell">
<lang PowerShell>
db -LatestByCategory
db -LatestByCategory
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
Line 3,489: Line 3,489:
</pre>
</pre>
The database sorted on the Birthday property:
The database sorted on the Birthday property:
<syntaxhighlight lang="powershell">
<lang PowerShell>
db -SortedByDate
db -SortedByDate
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
Line 3,505: Line 3,505:


=={{header|Python}}==
=={{header|Python}}==
<lang python>#!/usr/bin/python3
<syntaxhighlight lang="python">#!/usr/bin/python3


'''\
'''\
Line 3,612: Line 3,612:
now = datetime.datetime.utcnow()
now = datetime.datetime.utcnow()
args._date = now.isoformat()
args._date = now.isoformat()
do_command[args.command](args, dbname)</lang>
do_command[args.command](args, dbname)</syntaxhighlight>


;Sample session (Unix):
;Sample session (Unix):
Line 3,660: Line 3,660:


=={{header|Racket}}==
=={{header|Racket}}==
<lang racket>
<syntaxhighlight lang="racket">
#!/usr/bin/env racket
#!/usr/bin/env racket
#lang racket
#lang racket
Line 3,687: Line 3,687:
(for-each (compose1 show last/cat) (remove-duplicates (map cadr data)))]
(for-each (compose1 show last/cat) (remove-duplicates (map cadr data)))]
[else (error 'sdb "bad printout mode")])])
[else (error 'sdb "bad printout mode")])])
</syntaxhighlight>
</lang>


Sample run:
Sample run:
Line 3,727: Line 3,727:
A generic client/server JSON database.<br>
A generic client/server JSON database.<br>
<b>server.raku:</b>
<b>server.raku:</b>
<lang perl6>#!/usr/bin/env raku
<syntaxhighlight lang="raku" line>#!/usr/bin/env raku
use JSON::Fast ;
use JSON::Fast ;
sub MAIN( :$server='0.0.0.0', :$port=3333, :$dbfile='db' ) {
sub MAIN( :$server='0.0.0.0', :$port=3333, :$dbfile='db' ) {
Line 3,830: Line 3,830:
spurt "{$dbfile}_index.json", to-json(%index) ;
spurt "{$dbfile}_index.json", to-json(%index) ;
}
}
}</lang>
}</syntaxhighlight>
<b>client.raku:</b>
<b>client.raku:</b>
<lang perl6>#!/usr/bin/env raku
<syntaxhighlight lang="raku" line>#!/usr/bin/env raku
use JSON::Fast ;
use JSON::Fast ;
multi MAIN('set', $topic, $message='', :$server='localhost', :$port='3333', :$json='') {
multi MAIN('set', $topic, $message='', :$server='localhost', :$port='3333', :$json='') {
Line 3,881: Line 3,881:
}
}
}
}
}</lang>
}</syntaxhighlight>
Example:
Example:
<pre>./client.raku addindex constructor
<pre>./client.raku addindex constructor
Line 3,903: Line 3,903:


=={{header|REBOL}}==
=={{header|REBOL}}==
<lang rebol>rebol [author: "Nick Antonaccio"]
<syntaxhighlight lang="rebol">rebol [author: "Nick Antonaccio"]
write/append %rdb "" db: load %rdb
write/append %rdb "" db: load %rdb
switch system/options/args/1 [
switch system/options/args/1 [
Line 3,917: Line 3,917:
"sort" [probe sort/skip db 4]
"sort" [probe sort/skip db 4]
]
]
halt</lang>
halt</syntaxhighlight>


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/* REXX ---------------------------------------------------------------
<syntaxhighlight lang="rexx">/* REXX ---------------------------------------------------------------
* 05.10.2014
* 05.10.2014
*--------------------------------------------------------------------*/
*--------------------------------------------------------------------*/
Line 3,996: Line 3,996:
Say 'end to end this program'
Say 'end to end this program'
Say 'Use category - to list items without category'
Say 'Use category - to list items without category'
Return</lang>
Return</syntaxhighlight>
{{out}}
{{out}}
<pre> Enter your commands, ?, or end
<pre> Enter your commands, ?, or end
Line 4,033: Line 4,033:


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>require 'date'
<syntaxhighlight lang="ruby">require 'date'
require 'json'
require 'json'
require 'securerandom'
require 'securerandom'
Line 4,219: Line 4,219:
end
end


process_command_line *ARGV</lang>
process_command_line *ARGV</syntaxhighlight>


Sample session
Sample session
Line 4,298: Line 4,298:


=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<lang runbasic>sqliteconnect #sql, "f:\client.db" ' Connect to the DB
<syntaxhighlight lang="runbasic">sqliteconnect #sql, "f:\client.db" ' Connect to the DB


' -------------------------------
' -------------------------------
Line 4,397: Line 4,397:
' ------ the end -------
' ------ the end -------
[exit]
[exit]
end</lang>
end</syntaxhighlight>
Output:
Output:


Line 4,433: Line 4,433:


=={{header|Scala}}==
=={{header|Scala}}==
<lang Scala>object SimpleDatabase extends App {
<syntaxhighlight lang="scala">object SimpleDatabase extends App {
type Entry = Array[String]
type Entry = Array[String]
def asTSV(e: Entry) = e mkString "\t"
def asTSV(e: Entry) = e mkString "\t"
Line 4,470: Line 4,470:
case _ => println("Usage: SimpleDatabase filename.tsv [all [latest]| latest [CATEGORY] | add [DESCRIPTION [CATEGORY [OPTIONAL]...]]]")
case _ => println("Usage: SimpleDatabase filename.tsv [all [latest]| latest [CATEGORY] | add [DESCRIPTION [CATEGORY [OPTIONAL]...]]]")
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>> SimpleDatabase
<pre>> SimpleDatabase
Line 4,508: Line 4,508:
=={{header|Tcl}}==
=={{header|Tcl}}==
The format used is that of a Tcl dictionary, where each entry uses the title as a key and the remaining information (category, date and miscellaneous metadata) is the value associated with it. The only variation from the standard internal format is that entries are separated by newlines instead of spaces; this is still a legal value, but is a non-canonical.
The format used is that of a Tcl dictionary, where each entry uses the title as a key and the remaining information (category, date and miscellaneous metadata) is the value associated with it. The only variation from the standard internal format is that entries are separated by newlines instead of spaces; this is still a legal value, but is a non-canonical.
<lang tcl>#!/usr/bin/env tclsh8.6
<syntaxhighlight lang="tcl">#!/usr/bin/env tclsh8.6
package require Tcl 8.6
package require Tcl 8.6
namespace eval udb {
namespace eval udb {
Line 4,608: Line 4,608:
}
}


udb::Store [lindex $argv 0]</lang>
udb::Store [lindex $argv 0]</syntaxhighlight>
Sample session:
Sample session:
<lang bash>bash$ udb.tcl db
<syntaxhighlight lang="bash">bash$ udb.tcl db
wrong # args: should be "udb.tcl dbfile subcommand ?args...?"
wrong # args: should be "udb.tcl dbfile subcommand ?args...?"
bash$ udb.tcl db ?
bash$ udb.tcl db ?
Line 4,700: Line 4,700:
Title: Title 3
Title: Title 3
Category: bar
Category: bar
Date: Tue Nov 15 18:12:07 GMT 2011</lang>
Date: Tue Nov 15 18:12:07 GMT 2011</syntaxhighlight>


=={{header|ToffeeScript}}==
=={{header|ToffeeScript}}==
<lang coffeescript>#!/usr/local/bin/toffee
<syntaxhighlight lang="coffeescript">#!/usr/local/bin/toffee


prog = require 'commander'
prog = require 'commander'
Line 4,787: Line 4,787:
printFormatted entry
printFormatted entry


prog.parse process.argv</lang>
prog.parse process.argv</syntaxhighlight>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
This format is guaranteed to be human readable: if you can type it, you can read it.
This format is guaranteed to be human readable: if you can type it, you can read it.
<lang bash>#!/bin/sh
<syntaxhighlight lang="bash">#!/bin/sh


db_create() {
db_create() {
Line 4,886: Line 4,886:
show_help
show_help
;;
;;
esac</lang>
esac</syntaxhighlight>
Sample usage (assuming script is named "sdb"):<lang>$ sdb create CDs
Sample usage (assuming script is named "sdb"):<syntaxhighlight lang="text">$ sdb create CDs
Create DB `CDs'
Create DB `CDs'
$ sdb add CDs Bookends
$ sdb add CDs Bookends
Line 4,923: Line 4,923:
$ sdb drop CDs
$ sdb drop CDs
Delete DB `CDs'
Delete DB `CDs'
$</lang>
$</syntaxhighlight>


=={{header|Wren}}==
=={{header|Wren}}==
Line 4,933: Line 4,933:
{{libheader|Wren-str}}
{{libheader|Wren-str}}
Note that since Wren CLI currently has no way of determining the current date/time, a date needs to be input for each item to be added.
Note that since Wren CLI currently has no way of determining the current date/time, a date needs to be input for each item to be added.
<lang ecmascript>/* simdb.wren */
<syntaxhighlight lang="ecmascript">/* simdb.wren */


import "os" for Process
import "os" for Process
Line 5,051: Line 5,051:
} else {
} else {
printUsage.call()
printUsage.call()
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}