Good Afternoon,
do you know why sql lite is performing very slow on raspberry ?
for update a row bring about 3 seconds too much,
thanks in advance for the support,
br
Andrea
Code: Select all
using SQLite.Net.Attributes;
namespace Audio
{
/// <summary>
/// In questo punto si struttura il Database che sarà inviato a raspberry
/// </summary>
public class Contabilita
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public float NumberOfCredit { get; set; } // Numero di crediti dopo inserimento moneta
public float NumberOfMatches { get; set; } // Numero di partite Totali giocate
public float NumberOfTotalCoin { get; set;} // Numero Totale di Crediti
public float NumberOfWinMatches { get; set; } // Numero Totale di Partite Vinte
}
Code: Select all
string path;
SQLite.Net.SQLiteConnection conn;
Code: Select all
public void ConnectToDatabase()
{
path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
//path = Path.Combine("C:\\DB", "db.sqlite");
//using (var conn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
//{
// conn.CreateTable<Contabilita>();
// conn.RunInTransaction(() =>
// {
// conn.Insert(new Contabilita()
// {
// NumberOfCredit = 1,
// NumberOfMatches = 0,
// NumberOfTotalCoin = 0,
// NumberOfWinMatches = 0
// });
// });
//}
conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
//conn.DeleteAll<Contabilita>();
//conn.CreateTable<Contabilita>();
//conn.Insert(new Contabilita()
//{
// NumberOfCredit = 1,
// NumberOfMatches = 0,
// NumberOfTotalCoin = 0,
// NumberOfWinMatches = 0
//});
// conn.Commit();
}
Code: Select all
public void ReadContabilita(ref float NumeroCrediti, ref float NumeroPartite, ref float NumerodiMonete, ref float NumeroPartiteVinte)
{
var tmp = conn.Table<Contabilita>().FirstOrDefault();
NumeroCrediti = tmp.NumberOfCredit;
NumeroPartite = tmp.NumberOfMatches;
NumerodiMonete = tmp.NumberOfTotalCoin;
NumeroPartiteVinte = tmp.NumberOfWinMatches;
}
Code: Select all
public void UpdateContabilita(float NumeroCrediti, float NumeroPartite, float NumerodiMonete, float NumeroPartiteVinte)
{
// var tmp = conn.Table<Contabilita>().FirstOrDefault(c => c.Id == 0);
var tmp = conn.Table<Contabilita>().FirstOrDefault();
tmp.NumberOfCredit = NumeroCrediti;
tmp.NumberOfMatches = NumeroPartite;
tmp.NumberOfTotalCoin = NumerodiMonete;
tmp.NumberOfWinMatches = NumeroPartiteVinte;
conn.Update(tmp);
conn.Commit();
}