Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Prathapachandran

@Prathapachandran
About
Posts
5
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • SQLite in-memory database - Loading sqlite db as memory db
    P Prathapachandran

    Thanks for the input. I have written my own code to implement it. Please find the bellow steps. 1. Import the below Native methods

    \[DllImport("System.Data.SQLite.dll")\]
    public static extern int sqlite3\_backup\_init(IntPtr pTo, string toName, IntPtr pFrom, string fromName);
    
    \[DllImport("System.Data.SQLite.dll")\]
    public static extern int sqlite3\_backup\_step(int b, int n);
    
    \[DllImport("System.Data.SQLite.dll")\]
    public static extern int sqlite3\_backup\_finish(int backupObject);
    
    \[DllImport("System.Data.SQLite.dll")\]
    public static extern int sqlite3\_sleep(int interval);
    
    \[DllImport("System.Data.SQLite.dll")\]
    public static extern int sqlite3\_backup\_remaining(int remaining);
    
    \[DllImport("System.Data.SQLite.dll")\]
    public static extern int sqlite3\_backup\_pagecount(int pageCount);
    

    2. Define the below constants

     public const int SQLITE\_OK = 0;
     public const int SQLITE\_BUSY = 5;
     public const int SQLITE\_LOCKED = 6;
    

    3. Above APIs required database as IntPtr. But we have only a connection class [System.Data.SQLite.SQLiteConnection]. So we need to find out database handle from the connection object. I don't know whether it is a right way or not, anyway implement an extension method as shown below

        public static IntPtr GetConnectionHandle(this SQLiteConnection connection)
        {
            IntPtr returnPointer = IntPtr.Zero;
            FieldInfo\[\] fields = typeof(SQLiteConnection).GetFields(
                    BindingFlags.NonPublic | BindingFlags.Instance |
                    BindingFlags.DeclaredOnly);
            object sqLiteBase = null;
            object value = null;
    
            //Checks the valid connection states
            if (connection.State != System.Data.ConnectionState.Open &&
                connection.State != System.Data.ConnectionState.Fetching &&
                connection.State != System.Data.ConnectionState.Executing)
            {
                return returnPointer;
            }
            foreach (FieldInfo info in fields)
            {
                //Getting the object "internal SQLiteBase \_sql;" from the 
                //public class instance System.Data.SQLite.SQLiteConnection.
                if (string.Compare(info.Name, "\_sql", true) == 0)
                {                   
                    sqLiteBase = info.GetValue(connection);
                    break;
    
    Database database csharp sqlite performance help

  • SQLite in-memory database - Loading sqlite db as memory db
    P Prathapachandran

    In-memory database means, all the database schema and data will reside in memory and we can use any supported SQL queries to manipulate data in the memory-db. But when the memory-db connection is closed, that data will be lost. Normally this concept is used for very fast database operations. we can use the below connection string to create an in-memory db in sqlite.

    public const string sqliteConnectionString = "Data Source=:memory:";

    visit the link http://www.sqlite.org/inmemorydb.html[^] for getting more idea about it.

    Database database csharp sqlite performance help

  • SQLite in-memory database - Loading sqlite db as memory db
    P Prathapachandran

    Thanks for the reply. But how to use it in C#? Do I need to write a wrapper like in the article http://www.switchonthecode.com/tutorials/csharp-tutorial-writing-a-dotnet-wrapper-for-sqlite[^]? I am doing all the db operations using ADO.NET sqlite provider libary (System.Data.SQLite). :(

    Database database csharp sqlite performance help

  • SQLite in-memory database - Loading sqlite db as memory db
    P Prathapachandran

    I already read this documentation, but did't find any solution.. :(

    Database database csharp sqlite performance help

  • SQLite in-memory database - Loading sqlite db as memory db
    P Prathapachandran

    I have an SQLite database and I need to load the database as in-memory database. Is it any way to do this? I am using ADO.NET Data Provider library for SQLite to do all the DB Operations. Please help.

    Database database csharp sqlite performance help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups