private static void CreateTables(sqlite3 handle, List <string> tableNames, LiteWriter writer) { foreach (var tableName in tableNames) { var stmt = SQLite3.Prepare2(handle, "pragma table_info(" + tableName + ")"); try { int offset = 0; List <Column> columns = new List <Column>(); while (SQLite3.Step(stmt) == SQLite3.Result.Row) { string name = SQLite3.ColumnString(stmt, 1); string type = SQLite3.ColumnString(stmt, 2); int notNull = SQLite3.ColumnInt(stmt, 3); var ct = GetType(type); var column = new Column(name, ct, offset); columns.Add(column); offset += LiteData.GetLength(ct); } var columnArray = new Column[columns.Count]; columns.CopyTo(columnArray); var table = writer.AddTable(tableName, columnArray, offset); AddRows(handle, table); } finally { SQLite3.Finalize(stmt); } } }
public void Write(int columnIndex, float value) { var column = table.Columns[columnIndex]; if (column.Type != ColumnType.Single) { throw new InvalidCastException(); } LiteData.WriteSingle(data, column.Offset, value); }
public void Write(int columnIndex, string value) { var column = table.Columns[columnIndex]; if (column.Type != ColumnType.String) { throw new InvalidCastException(); } int index = table.Writer.AddString(value); LiteData.WriteInt32(data, column.Offset, index); }