Exemple #1
0
        public static void CreateSettingsDatabase()
        {
            File.Delete(QSqlLite.databaseName);
            QSqlLite.CreateDatabase(QSqlLite.databaseName);
            using (QSqlLite s = new QSqlLite())
            {
                #region create structure
                s.Execute(@"
create table init_settings (
loadDatabase int not null default 0,
databaseId int not null,
maximized integer default 1 not null,
screen text not null default '' ,
width integer not null default 0,
height integer not null default 0,
horzSplitterPos integer not null default 0,
vertSplitterPos integer not null default 0,
dark integer not null default 1,
shutDownClean not null default 0,
lastLoadTime integer not null default 0,
avgLoadTime integer not null default 0
)");

                s.Execute(@"
create table databases (
databaseId int not null primary key,
database text not null,
host text not null,
type text not null,
user text not null,
password text not null,
unique (database,host)
)");

                s.Execute(@"
CREATE TABLE tables (
databaseId int not null,
name text not null,
lastAnalyzed integer not null default 0,
lastUsed integer not null default 0,
useCount integer not null default 0,
rowCount integer not null default 0,
bookmarked integer not null default 0,
showAllColumns integer not null default 0
)");
                s.Execute(@"
CREATE TABLE table_columns (
databaseId int not null,
tableName text not null, 
columnName text not null,
columnType text not null,
bookmarked integer not null default 0,
lastAnalyzed integer not null default 0,
lastUsed integer not null default 0,
useCount integer not null default 0,
cardinality real not null default 0,
fullness real not null default 0,
uniqueValues integer not null default 0,
nonEmptyValues integer not null default 0,
minValue text not null,
maxValue text not null
)");
                s.Execute(@"
CREATE TABLE table_aliases (
databaseId int not null,
tableName text not null, 
alias text not null,
lastAnalyzed integer not null default 0,
lastUsed integer not null default 0,
useCount integer not null default 0
)");


                s.Execute(@"
CREATE TABLE settings (
name text not null unique,
value text not null)");

                s.Execute(@"
CREATE TABLE tabs (
databaseId int not null,
id integer  NOT NULL PRIMARY KEY,
pos integer  NOT NULL DEFAULT 0,
name text  NOT NULL,
visible integer  NOT NULL DEFAULT 1)");

                s.Execute(@"
 CREATE TABLE queries (
id integer NOT NULL PRIMARY KEY,
tab_id integer NOT NULL,
failed integer NOT NULL default 0,
expr text DEFAULT NULL,
rows integer null,
ms text null,
    when_changed text NOT NULL
    )  ");
                #endregion
            }
        }