14.3 Database commands
These commands are useful to manage the databases by scripting languages.
DBCLOSE (UINT)Handle
Close the database and release its resources.
Parameters: | ||
Handle | It's the database handle returned by DBOPEN command. |
Return values:
If it fails (e.g. the database is already closed or the handle is invalid), 0
(false) is returned, otherwise 1 (true) is set.
Example:
DBCLOSE 13423
See also:
DBCREATE,
DBOPEN,
DBGET,
DBGETID,
DBPUT.
DBCREATE (CHAR)FileName (CHAR)DbaseFormat
(CHAR)MolFormat (CHAR)MolCompression (INT)Flags
Create a new empty database. Please remember that you need to call the DBOPEN
to change the database contents after its creation.
Parameters: | ||||||||||||||
FileName | File or directory name with or without full path. The extension is added automatically if needed. | |||||||||||||
DbaseFormat | Database format. The allowed keywords are: | |||||||||||||
|
||||||||||||||
MolFormat |
Default molecule format (see -f command line option). This field is ignored by Access, SD file and SQLite database formats. |
|||||||||||||
MolCompression |
Default molecule compression (NONE, BZIP2, GZIP, POWERPACKER, ZCOMPRESS). This field is ignored by Access, SD file, SQLite and Zip database formats. |
|||||||||||||
Flags | Default database flags. These flags can be combined
by OR operator.
|
Return values:
Error code if it fails.
Example:
DBCREATE "NewDatabase" zip pdb
none 0
See also:
DBCLOSE,
DBOPEN,
DBGET,
DBGETID,
DBPUT.
DBGET (UINT)Handle (CHAR)MolName
(MCHAR)Mode
Extract a molecule from the database specifying its name.
Parameters: | ||||||||||
Handle | It's the database handle returned by DBOPEN command. | |||||||||
MolName | Name of the molecule to extract (with file extension). | |||||||||
Mode | It's the extraction mode, that can be:
|
Return values:
If it fails (e.g. the database handle is invalid or the molecule name is wrong), 0
(false) is returned, otherwise 1 (true) is set.
Example:
DBGET 13423 Water.iff Replace
See also:
DBOPEN,
DBCLOSE,
DBGETID,
DBGETROWID,
DBPUT.
DBGETID (UINT)Handle (CHAR)MolID
(MCHAR)Mode
Extract a molecule from the database specifying its identification number
(ID). Each database record has an ID that is a progressive number starting from
zero to the total number of records minus one. To obtain the total number of
molecules in the database, see DBINFO command.
Parameters: | ||||||||||
Handle | It's the database handle returned by the DBOPEN command. | |||||||||
MolID | Molecule identification number. | |||||||||
Mode | It's the extraction mode, that can be:
|
Return values:
If it fails (e.g. the database handle is invalid or the molecule ID is wrong), 0
(false) is returned, otherwise 1 (true) is set.
Example:
DBGETID 13423 4 Replace
See also:
DBOPEN,
DBCLOSE,
DBGET,
DBGETROWID,
DBINFO,
DBPUT.
DBGETROWID (UINT)Handle (CHAR)RowID
(MCHAR)Mode
Extract a molecule from the database specifying its primary key (Row ID).
This command is useful for SQL databases in which each record has an unique ID.
If the database is not SQL, the command is automatically translated to
DBGETID.
Parameters: | ||||||||||
Handle | It's the database handle returned by the DBOPEN command. | |||||||||
RowD | Primary key. | |||||||||
Mode | It's the extraction mode, that can be:
|
Return values:
If it fails (e.g. the database handle is invalid or the row ID is invalid), 0
(false) is returned, otherwise 1 (true) is set.
Example:
DBGETROWID 13423 98 Add
See also:
DBOPEN,
DBCLOSE,
DBGET,
DBGETID,
DBINFO,
DBPUT.
DBINFO (UINT)Handle (MCHAR)Variable
Obtain the value of a database variable.
Parameters: | ||||||||||||||||
Handle | Database handle returned by DBOPEN command. | |||||||||||||||
Variable | Database system variable. It can be:
|
Return values:
If the database exists, the variable value is returned.
Example:
DBINFO 26123 MOLECULES
See also:
DBCLOSE,
DBGET,
DGETID,
DBOPEN,
DBPUT.
DBLOCK (UINT)Handle
(BOOL)Lock
Lock/unlock an existing database. The lock status avoids to close accidentally
the database.
Parameters: | |||
Handle | Database handle returned by DBOPEN command. | ||
Lock | 0 (false) = unlock the database. 1 (true) = lock the database. |
Return values:
Error code if it fails.
Example:
DBLOCK 12432 1
See also:
DBCLOSE,
DBCREATE,
DBOPEN.
DBOPEN (CHAR)DbName
Open an existing database. This command is required to access (read and write
operation) to an existing database.
Parameters: | ||
DbName | Database file name whit full path. |
Return values:
If the database exists, its handle is returned, otherwise the function returns 0
(error condition).
Example:
DBOPEN "Vega\Data\Fragments\Solvents.zip"
See also:
DBCLOSE,
DBCREATE,
DBGET,
DBGETID,
DBINFO,
DBPUT.
DBPUT (UINT)Handle (CHAR)MolName
Put the current molecule in the specified database.
Parameters: | ||
Handle | It's the database handle returned by the DBOPEN command.. | |
NolName | Name of the molecule to put with the file extension, if the database format requires it (e.g. file and zip). If the molecule is already present in the database, it will be replaced by the new one (update mode). |
Return values:
If it fails (e.g. the database handle is invalid), 0
(false) is returned, otherwise 1 (true) is set.
Example:
DBPUT 13182 "MyMolecule"
See also:
DBCLOSE,
DBCREATE,
DBGET,
DBGETID,
DBINFO,
DBOPEN.