IntroductionIn this section you will see how to make a connection. If you find that the examples in this section do not work as shown, you may need to install or restore the example database with the DatabaseExamples` package.
Functions for working with Database connections. This loads DatabaseLink. Now you can connect to a named database, called demo, that is provided by DatabaseLink for documentation. The Connection Configuration section shows how to set up new named connections. You can learn about existing named connection in the Named Connections section.
| Out[2]= |  |
SQLConnections returns a list of all the open connections.
| Out[3]= |  |
OpenSQLConnection returns a Mathematica expression that refers to the connection. It can be used to make queries on the database. In the following example, the tables that are found in the database are returned. The functions for retrieving data from a database are discussed the Data Commands section.
| Out[4]= |  |
When you have finished with a connection, you can close it with CloseSQLConnection.
| Out[6]= |  |
There are a number of options that can be given to OpenSQLConnection.
OpenSQLConnection options. These options can be used when opening a connection. For instance, the following allows you to use a different username and password for the connection.
| Out[7]= |  |
If you enter $Prompt as a password, a dialog box opens that will prompt you for the password. This helps keep the password more secure. Another simple way to connect to a database is to use the Connection Tool, described in a later section.
|