00001
00002
00003
00004
00005
00006
00007
00008 #ifndef DATABASE_H
00009 #define DATABASE_H
00010
00011 #include <QCoreApplication>
00012 #include <QSqlDatabase>
00013 #include <QStringList>
00014
00015
00016 #define SESSION_NAME "sqliteman-db"
00017
00020 typedef struct
00021 {
00022 int cid;
00023 QString name;
00024 QString type;
00025 bool notnull;
00026 QString defval;
00027 bool pk;
00028 QString comment;
00029 }
00030 DatabaseTableField;
00031
00034 typedef QMap<QString,QString> DbAttach;
00035
00037 typedef QList<DatabaseTableField> FieldList;
00038
00040 typedef QMap<QString,QString> DbObjects;
00041
00042
00058 class Database
00059 {
00060 Q_DECLARE_TR_FUNCTIONS(Database)
00061
00062 public:
00063 static DbAttach getDatabases();
00070 static DbObjects getObjects(const QString type = 0, const QString schema = "main");
00071
00076 static DbObjects getSysObjects(const QString & schema = "main");
00077
00084 static QStringList getSysIndexes(const QString & table, const QString & schema);
00085
00090 static bool execSql(QString statement);
00091
00096 static QString sessionName(const QString & schema);
00097
00104 static bool dropTable(const QString & table, const QString & schema);
00105
00112 static bool dropTrigger(const QString & name, const QString & schema);
00113
00120 static FieldList tableFields(const QString & table, const QString & schema);
00121
00123 static QStringList indexFields(const QString & index, const QString &schema);
00124
00131 static bool dropView(const QString & view, const QString & schema);
00132
00139 static bool dropIndex(const QString & name, const QString & schema);
00140
00147 static bool exportSql(const QString & fileName);
00148
00149 static QString describeObject(const QString & name, const QString & schema = "main");
00150
00155 static QString hex(const QByteArray & val);
00156
00161 static QString pragma(const QString & name);
00162
00163 private:
00165 static void exception(const QString & message);
00166 };
00167
00168 #endif