Database - Maple Programming Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Connectivity : Database Package : Database/LoadConnection

Database

 LoadConnection
 load a saved Connection

 Calling Sequence LoadConnection( name, opts )

Parameters

 name - (optional) string; the identifier for the connection to load opts - (optional) equation(s) of the form option=value where option is one of filename or password

Description

 • LoadConnection re-establishes a connection that was saved using the Save command or Database Connection Maplet application.
 • Each connection that is saved using the Save command has an associated identifier. This identifier is used to distinguish between the connections saved in a file.  If specified, name is used as the identifier. Otherwise, "default" is used as the identifier.
 • The opts argument can contain one or more of the following equations.
 filename = string
 The filename option specifies the file from which this connection is loaded.  When no filename is given, connections are loaded from $HOME/maple/toolbox/Database/data/default.con, where$HOME is the value returned by kernelopts( homedir ).
 password = string or one of the literal symbols none or hidden
 The password option is used to specify the password to use when re-establishing the connection to the database.  If a password option is given, it overrides a password that is saved in the file.  If no password is saved in the file and a password is required to connect to the database, then the password option must be given.  If a string is given, that string is used as the password.  If hidden is given, then a Maplet application opens to allow you to enter a password without it appearing in the worksheet.  The default value is none.
 • Along with saving the parameters necessary to re-establish the connection, the Save command also stores the connection's current settings, as returned by the GetOptions command.  When a connection is loaded using the LoadConnection command, these settings are also restored.
 • LoadConnection returns an expression sequence of two modules.  The first module is the Database[Driver] module you used to open the connection.  The second is the Database[Connection] module representing the opened connection.

Examples

Create a connection.

 > $\mathrm{driver}≔\mathrm{Database}[\mathrm{LoadDriver}]\left(\right):$
 > $\mathrm{conn}≔\mathrm{driver}:-\mathrm{OpenConnection}\left(\mathrm{url},\mathrm{name},\mathrm{pass}\right):$

Save the connection to disk using the default file and the default identifier.

 > $\mathrm{conn}:-\mathrm{Save}\left(\right):$

Close the connection.

 > $\mathrm{conn}:-\mathrm{Close}\left(\right);$$\mathrm{driver}:-\mathrm{Close}\left(\right)$

Re-establish the connection saved as default.

 > $\mathrm{driver},\mathrm{conn}≔\mathrm{Database}[\mathrm{LoadConnection}]\left(\mathrm{password}='\mathrm{hidden}'\right):$

Modify this connection's options.

 > $\mathrm{conn}:-\mathrm{SetOptions}\left('\mathrm{autocommit}'=\mathrm{true}\right)$

Save using a different identifier and specify the password.

 > $\mathrm{conn}:-\mathrm{Save}\left("ac1",'\mathrm{password}'=\mathrm{pass}\right):$

Close the connection.

 > $\mathrm{conn}:-\mathrm{Close}\left(\right);$$\mathrm{driver}:-\mathrm{Close}\left(\right)$

Re-establish the "ac1" connection.

 > $\mathrm{driver},\mathrm{conn}≔\mathrm{Database}[\mathrm{LoadConnection}]\left("ac1"\right):$

Check this connection's options.

 > $\mathrm{conn}:-\mathrm{GetOptions}\left('\mathrm{autocommit}'\right)$
 $\left[{\mathrm{autocommit}}{=}{\mathrm{true}}\right]$ (1)

 See Also