#include <mysqldb.h>
Inheritance diagram for Dv::MySql::Db:
Public Member Functions | |
Db (const char *dbname=0, const char *username="root", const char *passwd=0, const char *hostname=0) | |
Open a connection, check result with Dv::Sql::Db::ok() and friends. | |
Db (const Dv::Util::Props &config, const std::string &prefix="") throw (Sql::Exception) | |
Get database name etc. from configuration Dv::Util::Props object. | |
virtual | ~Db () |
Destructor. | |
std::string | user () const |
Return user of this database connection. | |
std::string | passwd () const |
Return password used to open this connection. | |
std::string | database () const |
Return name of current database of connection. | |
bool | database (const std::string &database) |
Switch connection to another database. | |
std::vector< std::string > | databases () |
Return the names of all databases available through this connection. | |
std::vector< std::string > | tables () |
Return the names of all tables available in the current database. | |
std::vector< Sql::Field > | fields (const std::string &table) |
Return ordered list of fields in a table. | |
Private Member Functions | |
Db (const Db &) | |
Cctor is forbidden. | |
Db & | operator= (const Db &) |
Assignment is forbidden. | |
Sql::Command_ * | command_ (Sql::Command &cmd) |
Implementation of Sql::Db pure virtual factory function. | |
Private Attributes | |
void * | mysql_ |
std::string | user_ |
std::string | passwd_ |
Friends | |
class | Command_ |
Command_ has access to mdbms-dependent private info, e.g. mysql_. |
Definition at line 36 of file mysqldb.h.
|
Open a connection, check result with Dv::Sql::Db::ok() and friends.
|
|
Get database name etc. from configuration Dv::Util::Props object. The configuration file uses the following attribute names (each preceded by prefix): mysqldb = mysqluser = mysqlpasswd = mysqlhost = abc:mysqldb = abc:mysqluser = abc:mysqlpasswd = abc:mysqlhost = Example usage: (from tmysql.C in the distribution) try { static const std::string CONFIG("tmysql.config"); ifstream ifs(CONFIG.c_str()); if (!ifs) throw runtime_error(CONFIG+": cannot open"); Dv::Util::Props config(ifs); std::string dictfn(config["dict"]); MySql::Db db(config,"tmysql::"); .. catch (exception& e) { cerr << e.what() << endl; return 1; } tmeta::mysqldb=mysql tmeta::mysqluser=root #tmeta::mysqlpasswd= # tmysql::mysqldb=test tmysql::mysqluser=root #mysqlpasswd= dict=/usr/dict/words |
|
Destructor.
Reimplemented from Dv::Sql::Db. |
|
Cctor is forbidden.
Reimplemented from Dv::Sql::Db. |
|
Return user of this database connection.
Definition at line 97 of file mysqldb.h. References user_. |
|
Return password used to open this connection.
Definition at line 99 of file mysqldb.h. References passwd_. |
|
Return name of current database of connection.
Reimplemented from Dv::Sql::Db. |
|
Switch connection to another database.
Implements Dv::Sql::Db. |
|
Return the names of all databases available through this connection.
Implements Dv::Sql::Db. |
|
Return the names of all tables available in the current database.
Implements Dv::Sql::Db. |
|
Return ordered list of fields in a table.
Implements Dv::Sql::Db. |
|
Assignment is forbidden.
Reimplemented from Dv::Sql::Db. |
|
Implementation of Sql::Db pure virtual factory function.
|
|
Command_ has access to mdbms-dependent private info, e.g. mysql_.
|
|
|
|
Definition at line 114 of file mysqldb.h. Referenced by user(). |
|
Definition at line 115 of file mysqldb.h. Referenced by passwd(). |