Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create an in memory sqlite database?

Tags:

c#

sqlite

I have tried SQLiteConnection(":memory:") and SQLiteConnection("sqlite::memory:") but both of these fail with 'Invalid ConnectionString format'

like image 530
David Sykes Avatar asked Feb 07 '12 09:02

David Sykes


People also ask

Can SQLite be used as in-memory database?

SQLite in-memory databases are databases stored entirely in memory, not on disk. Use the special data source filename :memory: to create an in-memory database. When the connection is closed, the database is deleted.

How do I create an in-memory database?

Use create inmemory database to create an in-memory database, using model or another user database as its template. You can also create temporary databases as in-memory databases that reside entirely in in-memory storage. However, you cannot specify a template database for an in-memory temporary database.

What is the command used to create a database in SQLite?

In SQLite, sqlite3 command is used to create a new SQLite database.

What is in-memory database example?

It means that each time you query a database or update data in a database, you only access the main memory. So, there's no disk involved into these operations. And this is good, because the main memory is way faster than any disk. A good example of such a database is Memcached.


1 Answers

try

var connection = new SQLiteConnection("Data Source=:memory:"); 
like image 85
Yahia Avatar answered Oct 09 '22 11:10

Yahia