Sipick
Sipick

Reputation: 71

SQLite execute VACUUM

I have updated NuGet packages from 'sqlite-net-pcl' for SQLite, after this I receive following error when performing vacuum:

'SQLite.SQLiteException: 'SQL logic error'

I have the following code for vacuum query:

_connection.Execute("vacuum");

I tried SQLiteCommand and create a command, but it gave me the same error. This code was OK before I update from package version 1.3.3 to 1.7.335.

Upvotes: 2

Views: 1461

Answers (1)

Diego Montania
Diego Montania

Reputation: 346

using System.Data.SQLite, vacuum only works, after deleting the tables.

I was not able to initialize my dataBase file using the corrects arguments to create a file with 'automatic vacuum'. This is the best way to deal with this situation.

using System.Data.SQLite;
...

cmd.CommandText = $"DROP TABLE MyTable;";
cmd.ExecuteNonQuery();

cmd.CommandText = $"vacuum;";
cmd.ExecuteNonQuery();

This is not a best approach, but works well to my purposes.

Upvotes: 1

Related Questions