0

I am trying to serialize my in memory Sqlite db, so I can convert it back into a file later on. I see how you would serialize the db in node.js How does `db.serialize` work in `node-sqlite3` and in C Serialize a database in C. I just have not been able to find a way to accomplish this in C#. If anyone has any insight it would be appreciated!
What I have so far

using System.Data.SQLite;
using Newtonsoft.Json;
using System.Text;

public byte[] SerializeDB(string sql)
{
   using(var con = new SQLiteConnection($"Data Source=:memory:;Version=3;New=True;")) {
     con.Open();
     using(SQLiteCommand cmd = new SQLiteCommand(sql, con)) {
       cmd.ExecuteNonQuery();

       return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(**WHAT SHOULD GO HERE**));
     }
   }
}
bmurf17
  • 83
  • 7

1 Answers1

0

After looking into further, I think that it is impossible. SQLite does not let you access the in memory file. This could work great if I was willing to back the file up and then access the backup. But then I would not have any need for the in memory file.

bmurf17
  • 83
  • 7
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 08 '22 at 06:10