Home

ad-hoc inspecting SQLite files

I have lots (100s, potentially 1000s) of sqlite files lying around, and I'd like to be able to open them in linqpad to have a look at what is going on, and then move on. Is there some way of invoking linqpad with

Linqpad6.exe --type sqlite --temporary my_db.sqlite

Which then open linqpad, and set up the connection just for that session?

Comments

  • I got most of what i want done by writing out a .linq file with the connection in, then launching that. That's probably good enough for now.

  • edited October 2020

    For 100 or 1000s of sqlite files, why don't you iterate the files and dump the tables?

    var files = Directory.EnumerateFiles(@"D:\Projects", "*.sqlite", SearchOption.AllDirectories);
    
    foreach (var file in files)
    {
      var builder = new SqliteConnectionStringBuilder { DataSource = file };
    
      using (var conn = new SqliteConnection(builder.ConnectionString))
      using (var cmd = conn.CreateCommand())
      {
        conn.Open();
    
        cmd.CommandText = "SELECT name, sql FROM sqlite_master WHERE type='table' ORDER BY name";
    
        using (var reader = cmd.ExecuteReader())
        {
          reader.Dump(file);
        }
      }
    }
    
  • I mean there are lots that I could potentially look at, but a couple that I want to look at now, but then possibly never again. I don't want to have to set up and remove connections for them each time.

  • Ah yes, then the ad hoc .linq file approach fits best I think.

  • It would be nice if there was a way to create the connection in the query dynamically using a LINQPad driver...

Sign In or Register to comment.