Example #1
0
        static void DumpSqlite(string filename)
        {
            Serializer s = new Serializer();
            try
            {
                var db = new SQLiteDatabase(filename);
                List <String> tableList = db.GetTables();
                List<SerializableDictionary<string, string>> dictList = new List<SerializableDictionary<string, string>>();
                foreach (string table in tableList)
                    {
                        String query = string.Format("select * from {0};", table);
                        DataTable recipe = db.GetDataTable(query);
                        foreach (DataRow r in recipe.Rows)
                            {
                                SerializableDictionary<string, string> item = new SerializableDictionary<string, string>();
                                foreach (DataColumn c in recipe.Columns)
                                    {
                                        item[c.ToString()] = r[c.ToString()].ToString();
                                    }
                                dictList.Add(item);
                            }
                        s.Serialize(string.Format("{0}.xml", table), dictList, table);
                        dictList.Clear();
                    }

            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message + "\n\n";
            }
        }