// @(#)root/mysql:$Id$
// Author: Fons Rademakers   15/02/2000

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TMySQLServer
#define ROOT_TMySQLServer

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TMySQLServer                                                         //
//                                                                      //
// MySQL server plugin implementing the TSQLServer interface.           //
//                                                                      //
// To open a connection to a server use the static method Connect().    //
// The db argument of Connect() is of the form:                         //
//    mysql://<host>[:<port>][/<database>], e.g.                        //
// mysql://pcroot.cern.ch:3456/test                                     //
//                                                                      //
// As an example of connecting to mysql we assume that the server is    //
// running on the local host and that you have access to a database     //
// named "test" by connecting using an account that has a username and  //
// password of "tuser" and "tpass". You can set up this account         //
// by using the "mysql" program to connect to the server as the MySQL   //
// root user and issuing the following statement:                       //
//                                                                      //
// mysql> GRANT ALL ON test.* TO 'tuser'@'localhost' IDENTIFIED BY 'tpass';
//                                                                      //
// If the test database does not exist, create it with this statement:  //
//                                                                      //
// mysql> CREATE DATABASE test;                                         //
//                                                                      //
// If you want to use a different server host, username, password,      //
// or database name, just substitute the appropriate values.            //
// To connect do:                                                       //
//                                                                      //
// TSQLServer *db = TSQLServer::Connect("mysql://localhost/test", "tuser", "tpass");
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TSQLServer
#include "TSQLServer.h"
#endif

#include <mysql.h>

class TMySQLServer : public TSQLServer {

protected:
   MYSQL     *fMySQL;    // connection to MySQL server
   TString    fInfo;     // server info string

public:
   TMySQLServer(const char *db, const char *uid, const char *pw);
   ~TMySQLServer();

   void           Close(Option_t *opt="");
   TSQLResult    *Query(const char *sql);
   Bool_t         Exec(const char* sql);
   TSQLStatement *Statement(const char *sql, Int_t = 100);
   Bool_t         HasStatement() const;
   Int_t          SelectDataBase(const char *dbname);
   TSQLResult    *GetDataBases(const char *wild = 0);
   TSQLResult    *GetTables(const char *dbname, const char *wild = 0);
   TList         *GetTablesList(const char* wild = 0);
   TSQLTableInfo *GetTableInfo(const char* tablename);
   TSQLResult    *GetColumns(const char *dbname, const char *table, const char *wild = 0);
   Int_t          GetMaxIdentifierLength() { return 64; }
   Int_t          CreateDataBase(const char *dbname);
   Int_t          DropDataBase(const char *dbname);
   Int_t          Reload();
   Int_t          Shutdown();
   const char    *ServerInfo();

   Bool_t         StartTransaction();
   Bool_t         Commit();
   Bool_t         Rollback();

   Bool_t         PingVerify();
   Int_t          Ping();

   ClassDef(TMySQLServer,0)  // Connection to MySQL server
};

#endif
 TMySQLServer.h:1
 TMySQLServer.h:2
 TMySQLServer.h:3
 TMySQLServer.h:4
 TMySQLServer.h:5
 TMySQLServer.h:6
 TMySQLServer.h:7
 TMySQLServer.h:8
 TMySQLServer.h:9
 TMySQLServer.h:10
 TMySQLServer.h:11
 TMySQLServer.h:12
 TMySQLServer.h:13
 TMySQLServer.h:14
 TMySQLServer.h:15
 TMySQLServer.h:16
 TMySQLServer.h:17
 TMySQLServer.h:18
 TMySQLServer.h:19
 TMySQLServer.h:20
 TMySQLServer.h:21
 TMySQLServer.h:22
 TMySQLServer.h:23
 TMySQLServer.h:24
 TMySQLServer.h:25
 TMySQLServer.h:26
 TMySQLServer.h:27
 TMySQLServer.h:28
 TMySQLServer.h:29
 TMySQLServer.h:30
 TMySQLServer.h:31
 TMySQLServer.h:32
 TMySQLServer.h:33
 TMySQLServer.h:34
 TMySQLServer.h:35
 TMySQLServer.h:36
 TMySQLServer.h:37
 TMySQLServer.h:38
 TMySQLServer.h:39
 TMySQLServer.h:40
 TMySQLServer.h:41
 TMySQLServer.h:42
 TMySQLServer.h:43
 TMySQLServer.h:44
 TMySQLServer.h:45
 TMySQLServer.h:46
 TMySQLServer.h:47
 TMySQLServer.h:48
 TMySQLServer.h:49
 TMySQLServer.h:50
 TMySQLServer.h:51
 TMySQLServer.h:52
 TMySQLServer.h:53
 TMySQLServer.h:54
 TMySQLServer.h:55
 TMySQLServer.h:56
 TMySQLServer.h:57
 TMySQLServer.h:58
 TMySQLServer.h:59
 TMySQLServer.h:60
 TMySQLServer.h:61
 TMySQLServer.h:62
 TMySQLServer.h:63
 TMySQLServer.h:64
 TMySQLServer.h:65
 TMySQLServer.h:66
 TMySQLServer.h:67
 TMySQLServer.h:68
 TMySQLServer.h:69
 TMySQLServer.h:70
 TMySQLServer.h:71
 TMySQLServer.h:72
 TMySQLServer.h:73
 TMySQLServer.h:74
 TMySQLServer.h:75
 TMySQLServer.h:76
 TMySQLServer.h:77
 TMySQLServer.h:78
 TMySQLServer.h:79
 TMySQLServer.h:80
 TMySQLServer.h:81
 TMySQLServer.h:82
 TMySQLServer.h:83
 TMySQLServer.h:84
 TMySQLServer.h:85
 TMySQLServer.h:86
 TMySQLServer.h:87
 TMySQLServer.h:88
 TMySQLServer.h:89
 TMySQLServer.h:90
 TMySQLServer.h:91