Macaulay2 » Documentation
Packages » Macaulay2Doc :: Database
next | previous | forward | backward | up | index | toc

Database -- the class of all database files

Description

A database file is just like a hash table, except both the keys and values have to be strings. In this example we create a database file, store a few entries, remove an entry with remove, close the file, and then remove the file.
i1 : filename = temporaryFileName () | ".dbm"

o1 = /tmp/M2-1930102-0/0.dbm
i2 : x = openDatabaseOut filename

o2 = /tmp/M2-1930102-0/0.dbm

o2 : Database
i3 : x#"first" = "hi there"

o3 = hi there
i4 : x#"first"

o4 = hi there
i5 : x#"second" = "ho there"

o5 = ho there
i6 : scanKeys(x,print)
second
first
i7 : remove(x,"second")
i8 : scanKeys(x,print)
first
i9 : close x

o9 = 0
i10 : removeFile filename

See also

Functions and methods returning a database :

Methods that use a database :

For the programmer

The object Database is a type, with ancestor class Thing.