Esempio n. 1
0
        public override void LoadStructure()
        {
            tables.Clear();

            using (QSqlLite s = new QSqlLite(file))
            {
                s.Open("SELECT name FROM sqlite_master WHERE type='table'");
                while (s.GetRow())
                {
                    DbTable t = new DbTable("", s[0], "BASE TABLE");
                    tables.Add(t.name, t);
                }

                foreach (DbTable t in tables.Values)
                {
                    s.Open("PRAGMA table_info(@1)", t.name);
                    while (s.GetRow())
                    {
                        string s0 = s[0];
                        string s1 = s[1];
                        string s2 = s[2];
                        string s3 = s[3];
                        string s4 = s[4];
                        string s5 = s[5];
//                        string s6 = s[6];

                        DbColumn c = new DbColumn(t, s[1], s[2],
                                                  s.GetBool(5),
                                                  !s.GetBool(3), s[4]);
                        t.columns.Add(c.name, c);
                        tablesByColumnName.Add(c.name, t);
                    }
                }
            }
        }
Esempio n. 2
0
        public static List <QueryInfo> GetQueryInfo(IEnumerable <int> ids)
        {
            List <QueryInfo> result = new List <QueryInfo>();
            string           idList = ids.Join();

            if (idList != "")
            {
                using (QSqlLite s = new QSqlLite())
                {
                    // this order will put the newest versions at the bottom of the results
                    // so if multiple version are opened, it will end up with the latest version anyways
                    s.Open(@"
select t.id, t.name, q.expr, t.visible, q.id 
from queries q 
inner join tabs t on t.id=q.tab_id 
where q.id in (" + idList + ") order by q.id");
                    while (s.GetRow())
                    {
                        result.Add(new QueryInfo {
                            queryVersionId = s.GetInt(4), visible = s.GetBool(3), queryId = s.GetInt(0), tabLabel = s.GetString(1), expr = s.GetString(2)
                        });
                    }
                }
            }

            return(result);
        }
Esempio n. 3
0
        public static List <QueryHistory> GetQueryHistory()
        {
            List <QueryHistory> result = new List <QueryHistory>();
            string sql = "t.databaseId=@1";

            if (S.Get("ShowClosedQueries", false))
            {
                sql = T.AppendTo(sql, "t.visible<>0", " and ");
            }
            if (sql != "")
            {
                sql = " where " + sql;
            }
            sql = @"
select q.id, q.tab_id, q.expr, q.when_changed, t.visible, t.name, q.failed, q.rows, q.ms
from queries q 
inner join tabs t on t.id=q.tab_id " + sql + " order by q.when_changed desc limit 100";
            using (QSqlLite s = new QSqlLite())
            {
                s.Open(sql, A.dbId);
                while (s.GetRow())
                {
                    string z = s.GetString(6);
                    result.Add(new QueryHistory
                    {
                        queryVersionId = s.GetInt(0),
                        id             = s.GetInt(1),
                        expr           = s.GetString(2),
                        whenChanged    = Convert.ToDouble(s.GetString(3)).ToDateTime(),
                        visible        = s.GetBool(4),
                        label          = s.GetString(5),
                        failed         = s.GetBool(6),
                        rows           = s.GetInt(7),
                        ms             = (s.GetString(8) == "" ? 0 : Convert.ToInt32(s.GetString(8)))
                    });
                }
            }

            return(result);
        }