In DB Browser for SQLite, How DO I Save An Edited FIle Without Changing Its Format?

647 Views Asked by At

I opened a file whose header says SQLite 3 and edited the value of 2 fields. I didn't change its structure. I tried saving, exporting etc but I never get a file with the same header as the original - and the program that uses this file says it is in the wrong format (or absent).

I tried the .dump command and got a file which begins: PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE locales ( locale_id INTEGER PRIMARY KEY AUTOINCREMENT, locale_uuid TEXT UNIQUE, locale_code TEXT

What I need is a file with the same format as the file I began my DB Browser for SQLite session by editing, which has these opening lines: SQLite 3 [the remaining characters result in an error message if I try pasting them in here) I see many characters did not paste well here! But you get the idea - the file I am able to save/export/dump out of the app is in plain text and the file I am trying to edit ONE PIECE OF DATA IN is not.

Perhaps I should have told you upfront these are my first 20 minutes in the world of editing SQL! (Mac 10.14.6)I will try to attach the file I started with.

Tried all the commands in the File menu - save, export. Tried terminal .dump

1

There are 1 best solutions below

5
Vector On

Just write an Update data routine. Here is code for a C# app It checks that the data is valid then when you click the update button presto magic data is updated

        private void btnUpdate_Click(object sender, System.EventArgs e)
    {
        if (!validateInput())
        {
            return;
        }
        if (!validateEmail())
        {
            return;
        }
        using (SQLiteConnection conn = new SQLiteConnection($"Data Source = '{dbName}';Version=3;"))
        {
            conn.Open();
            string sql = "UPDATE FriendsData SET fxFirstName = @fxFirstName, fxLastName = @fxLastName,fxAddress = @fxAddress,fxCity = @fxCity, fxState = @fxState,fxZip = @fxZip,fxCellPhone = @fxCellPhone,fxEmail = @fxEmail,fxInfo = @fxInfo WHERE FID =" + userData.udID;
            using (var cmd = new SQLiteCommand(sql, conn))
            {
                try
                {
                    cmd.Parameters.AddWithValue("@fxFirstName",tbFirstName.Text.Trim());
                    cmd.Parameters.AddWithValue("@fxLastName",tbLastName.Text.Trim());
                    cmd.Parameters.AddWithValue("@fxAddress",tbAddress.Text.Trim());
                    cmd.Parameters.AddWithValue("@fxCity",tbCity.Text.Trim());
                    cmd.Parameters.AddWithValue("@fxState",tbState.Text.Trim());
                    cmd.Parameters.AddWithValue("@fxZip",tbZip.Text.Trim());
                    cmd.Parameters.AddWithValue("@fxCellPhone",mtbCellPhone.Text.Trim());
                    cmd.Parameters.AddWithValue("@fxEmail",tbEmail.Text.Trim());
                    cmd.Parameters.AddWithValue("@fxInfo",rtbInfo.Rtf.Trim());

                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    result = ex.ToString();
                    tbMessage.Text = result;
                }
            }
        }
        tbMessage.Text = "Information Updated";
        btnUpdate.Enabled = false;
        btnClose.Focus();
    }