As per our observation, the initial write operations on the sqlite db file
throw "db is locked" error. After a certain time (around an hour) write
operations start working and we are able to do all the operations as
required.

On Mon, Jun 25, 2018 at 7:37 PM Phani Rahul Sivalenka
<rahul.sivale...@walkingtree.tech> wrote:

> > SQLiteConnectionStringBuilder connBuilder = new 
> > SQLiteConnectionStringBuilder();
>
>
>
> We are setting these configs via the connection string in xml. This is
> same as the above. The following is the connection string that we are using:
>
>
>
> “data
> source=/var/www/html/ChargerDatabase.db;DateTimeKind=Utc;Version=3;Pooling=True;Synchronous=Off;journal
> mode=Memory;Busy Timeout=30000;Default Timeout=30”
>
>
>
>
>
> >   Try setting the value to 30000 and see if this fixes your problem.
>
>
>
> “Busy Timeout” is set to 30000 as seen in the connection string.
>
> “Default Timeout” has a units of seconds as per the library and is the 
> timeout used for each command. This value is set to 30 sec.
>
>
>
>
>
> > How are you disposing of your SQLiteDataReader object after the reading is 
> > finished ?
>
>
>
> This is the format that we are following while using the reader or using 
> ExecuteNonQuery.
>
>
>
> using (SQLiteConnection connection = GetNewSQLiteConnection())
>
> {
>
>                 try
>
>                 {
>
>                                 connection.Open();
>
>
>
>                                 using (SQLiteCommand command = new
> SQLiteCommand(query, connection))
>
>                                 {
>
>                                                 // For Read Op ---------
>
>                                                 using (var reader =
> command.ExecuteReader())
>
>                                                 {
>
>                                                                 // ….
>
>
> reader.Close();
>
>                                                 }
>
>                                                 //
> ---------------------------
>
>
>
>                                                 // For Write Op --------
>
>                                                 result =
> command.ExecuteNonQuery();
>
>                                                 //
> --------------------------
>
>
>
>                                                 command.Reset();
>
>                                 }
>
>                 }
>
>                 catch(Exception ex)
>
>                 {
>
>                                 // ….
>
>                 }
>
>                 finally
>
>                 {
>
>                                 if (connection.State !=
> ConnectionState.Closed)
>
>                                 {
>
>                                                 connection.Close();
>
>                                 }
>
>                 }
>
> }
>
>
>
> Rahul.
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to