/// <summary>
        /// Helper function for testing the shapefile importer
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public static bool OpenShapefile(string filename, string tableName)
        {
            string databaseFileName = Path.Combine(Path.GetDirectoryName(filename), "shape.dat");
            var    client           = new SqliteDataClient(databaseFileName);

            using (DbConnection conn = client.GetConnection())
            {
                return(ShapefileHelper.ImportShapefile(conn, client, filename, tableName, -1));
            }
        }
        /// <summary>
        /// Helper function for checking structure of existing Db
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static DataTable GetSchema(SqliteDataClient client)
        {
            if (client == null)
            {
                return(null);
            }

            using (DbConnection conn = client.GetConnection())
            {
                //var dt = conn.GetSchema();
                return(conn.GetSchema("Tables"));
            }
        }
Beispiel #3
0
        public void TestSqliteGeneration()
        {
            var columns = new List <FixedWidthField>(new FixedWidthField[] {
                new FixedWidthField("FILEID", "File Identification", 6, 1),
                new FixedWidthField("WideText", "State Postal Abbreviation", 200, 7),
                new FixedWidthField("Numeric", "State Postal Abbreviation", 200, 7, FixedWidthTypes.INT),
            });

            string sql         = SqliteDataClient.GenerateTableSQLFromFields("test", columns);
            string expectedSql = "CREATE TABLE \"test\" ( ixid INTEGER NOT NULL PRIMARY KEY, FILEID TEXT(6), WideText TEXT(200), Numeric INTEGER(200) ); ";

            _log.Debug("Test generated " + sql);

            Assert.AreEqual(expectedSql, sql);
        }
        /// <summary>
        /// Helper function for testing the shapefile importer
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public static bool OpenShapefile(string filename, string tableName)
        {
            string databaseFileName = Path.Combine(Path.GetDirectoryName(filename), "shape.dat");
            var client = new SqliteDataClient(databaseFileName);

            using (DbConnection conn = client.GetConnection())
            {
                return ShapefileHelper.ImportShapefile(conn, client, filename, tableName, -1);
            }
        }
        /// <summary>
        /// Helper function for checking structure of existing Db
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static DataTable GetSchema(SqliteDataClient client)
        {
            if (client == null)
                return null;

            using (DbConnection conn = client.GetConnection())
            {
                //var dt = conn.GetSchema();
                return conn.GetSchema("Tables");
            }
        }