dbOpen#
Purpose#
Opens a specified database connection using the current connection values.
Format#
- ret = dbOpen(db_id[, user_name, password])#
- Parameters:
db_id (scalar) – database connection index number.
user_name (string) – optional. user name for the database being connected to.
password (string) – optional. password associated with the specified user name for this database.
- Returns:
ret (scalar) – 1 for success.
Examples#
Set driver and host
// Adds "MYSQL"" to the list of database connections
db_id = dbAddDatabase("MYSQL");
// Set database connection's hostname
dbSetHostName(db_id, "localhost");
then, either
// Set database username
dbSetUserName(db_id, "test");
// Set database password
dbSetPassword(db_id, "password");
// Open database connection
ret = dbOpen(db_id);
or
/*
** Open database connection
** using optional username input `test`
** and optional password input `password`
*/
ret = dbOpen(db_id, "test", "password");