Esempio n. 1
0
        public void Execute(ISemanticDatabase sdb, string sql)
        {
            NpgsqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = sql;
            sdb.LogSqlStatement(cmd.CommandText);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
        }
Esempio n. 2
0
		/// <summary>
		/// Return a list of all tables in the database.
		/// </summary>
		public List<string> GetTables(ISemanticDatabase sdb)
		{
			NpgsqlCommand cmd = conn.CreateCommand();
			cmd.CommandText = "SELECT table_name FROM information_schema.tables WHERE table_schema='public'";
			sdb.LogSqlStatement(cmd.CommandText);
			NpgsqlDataReader reader = cmd.ExecuteReader();
			List<string> tableNames = new List<string>();

			while (reader.Read())
			{
				tableNames.Add(reader[0].ToString());
			}

			return tableNames;
		}
Esempio n. 3
0
		/// <summary>
		/// Return a list of all tables in the database.
		/// </summary>
		public List<string> GetColumns(ISemanticDatabase sdb, string tableName)
		{
			NpgsqlCommand cmd = conn.CreateCommand();
			// currval() only works after an INSERT (which has executed nextval() ), in the same session.
			cmd.CommandText = "select column_name, data_type, character_maximum_length from INFORMATION_SCHEMA.COLUMNS where table_name = " + tableName.SingleQuote();
			sdb.LogSqlStatement(cmd.CommandText);
			NpgsqlDataReader reader = cmd.ExecuteReader();
			List<string> columnNames = new List<string>();

			while (reader.Read())
			{
				columnNames.Add(reader[0].ToString());
			}

			return columnNames;
		}
Esempio n. 4
0
        /// <summary>
        /// Return a list of all tables in the database.
        /// </summary>
        public List <string> GetTables(ISemanticDatabase sdb)
        {
            NpgsqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = "SELECT table_name FROM information_schema.tables WHERE table_schema='public'";
            sdb.LogSqlStatement(cmd.CommandText);
            NpgsqlDataReader reader     = cmd.ExecuteReader();
            List <string>    tableNames = new List <string>();

            while (reader.Read())
            {
                tableNames.Add(reader[0].ToString());
            }

            return(tableNames);
        }
Esempio n. 5
0
        /// <summary>
        /// Return a list of all tables in the database.
        /// </summary>
        public List <string> GetColumns(ISemanticDatabase sdb, string tableName)
        {
            SQLiteCommand cmd = conn.CreateCommand();

            cmd.CommandText = "pragma table_info('" + tableName + "')";
            sdb.LogSqlStatement(cmd.CommandText);
            SQLiteDataReader reader      = cmd.ExecuteReader();
            List <string>    columnNames = new List <string>();

            while (reader.Read())
            {
                columnNames.Add(reader[1].ToString());
            }

            return(columnNames);
        }
Esempio n. 6
0
        /// <summary>
        /// Return a list of all tables in the database.
        /// </summary>
        public List <string> GetTables(ISemanticDatabase sdb)
        {
            SQLiteCommand cmd = conn.CreateCommand();

            cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table'";
            sdb.LogSqlStatement(cmd.CommandText);
            SQLiteDataReader reader     = cmd.ExecuteReader();
            List <string>    tableNames = new List <string>();

            while (reader.Read())
            {
                tableNames.Add(reader[0].ToString());
            }

            return(tableNames);
        }
Esempio n. 7
0
        /// <summary>
        /// Return a list of all tables in the database.
        /// </summary>
        public List <string> GetColumns(ISemanticDatabase sdb, string tableName)
        {
            NpgsqlCommand cmd = conn.CreateCommand();

            // currval() only works after an INSERT (which has executed nextval() ), in the same session.
            cmd.CommandText = "select column_name, data_type, character_maximum_length from INFORMATION_SCHEMA.COLUMNS where table_name = " + tableName.SingleQuote();
            sdb.LogSqlStatement(cmd.CommandText);
            NpgsqlDataReader reader      = cmd.ExecuteReader();
            List <string>    columnNames = new List <string>();

            while (reader.Read())
            {
                columnNames.Add(reader[0].ToString());
            }

            return(columnNames);
        }
Esempio n. 8
0
		public void Execute(ISemanticDatabase sdb, string sql)
		{
			NpgsqlCommand cmd = conn.CreateCommand();
			cmd.CommandText = sql;
			sdb.LogSqlStatement(cmd.CommandText);
			cmd.ExecuteNonQuery();
			cmd.Dispose();
		}