Simple.Sqlite
0.7.4-alpha
See the version list below for details.
dotnet add package Simple.Sqlite --version 0.7.4-alpha
NuGet\Install-Package Simple.Sqlite -Version 0.7.4-alpha
<PackageReference Include="Simple.Sqlite" Version="0.7.4-alpha" />
paket add Simple.Sqlite --version 0.7.4-alpha
#r "nuget: Simple.Sqlite, 0.7.4-alpha"
// Install Simple.Sqlite as a Cake Addin #addin nuget:?package=Simple.Sqlite&version=0.7.4-alpha&prerelease // Install Simple.Sqlite as a Cake Tool #tool nuget:?package=Simple.Sqlite&version=0.7.4-alpha&prerelease
SqliteWrapper
A very simple Sqlite wrapper to plug spiders with it
Compatibility
Huge compatibility, supports:
- NET 5.0
- NetCore 3.1
- Net Framework 4.5
- Net Standard 2.0
Table of Contents
- SqliteWrapper
- SqliteDB - Sqlite wrapper
- NoSqliteStorage - No-sql document storage
- ConfigurationDB - Configuration storage
- Backup
- Reutilizing types
Modules and Options
There are three modules in this package
- SqliteDB → Sqlite wrapper
- No-sql document storage
- Configuration storage
How to get started:
Look at the examples int the project Test and the Samples folder
Or follow any of examples bellow
SqliteDB - Sqlite wrapper
Sqlite database to store data in tables
On new instance all database are backed up locally, see more here
How to use:
// Create a new instance
SqliteDB db = new SqliteDB("myStuff.db");
// Create a DB Schema
db.CreateTables()
.Add<MyData>()
.Commit();
var d = new MyData()
{
//fill your object
};
// call INSERT
db.Insert(d);
// use GetAll to retrieve all data
var allData = db.GetAll<MyData>();
// Use queries to get back data
var allBobs = db.ExecuteQuery<MyData>("SELECT * FROM MyData WHERE MyName = @name ", new { name = "bob" });
What this module automates ?
Auto fill parameters
This library provides a Query operation similar to Dapper, it can return a query as an Enumerable of your class
var allData = db.GetAll<MyData>();
And supports objects (even anonymous) as parameters
var allBobs = db.ExecuteQuery<MyData>("SELECT * FROM MyData WHERE MyName = @name ", new { name = "bob" });
Also, it supports easy Insertion
var d = new MyData()
{
//fill your object
};
// call INSERT
db.Insert(d);
And a VERY efficient, transaction based BulkInsertion
MyData[] lotsOfData = getLotsOfData();
// call INSERT
db.BulkInsert(lotsOfData);
Tip: For multi-million insertion, 5k blocks are a good start point
Migration
This library has a very simple Migration tah can:
- Create new tables
- Add columns to existing tables
To update your db schema just call CreateTables() and add your classes with Add<T>
and then Commit()
// Create a new instance
SqliteDB db = new SqliteDB("myStuff.db");
// Create a DB Schema
var migrationResult = db.CreateTables()
.Add<MyData>()
.Commit();
A TableCommitResult
will be returned with all changes made
This command will not migrate DATA only the schema
You can make changes on the table definition before it commits with:
db.CreateTables()
.Add<MyData>()
.ConfigureTable(t => { /* change last added table here */ })
.Add<NextTable>()
.Commit();
You can use Attributes on your properties to create columns marked with:
- PrimaryKey
- Allow Null
- Not Null
- Default Value
- Unique
// column tweak example
db.CreateTables()
.Add<MyData>()
.ConfigureTable(t => t["MyId"].IsUnique = true)
.Commit();
Also,
- Int properties with PK Attribute is also created as Auto-Increment
- If neither Not-Null nor Allow-Null is applied, the library will assume by the attribute type
NoSqliteStorage - No-sql document storage
Need a fast to setup, no-installation no-sql database ? This module get you covered
Your data will be stored encoded (serialized) with BSON
How to use:
// create a new instance
NoSqliteStorage db = new NoSqliteStorage("myStuff.db");
// build your complex type
MyData d = new MyData()
{
MyId = (int)DateTimeOffset.Now.ToUnixTimeSeconds(),
MyName = "My name is bob",
MyBirthDate = DateTime.Now,
MyUID = Guid.NewGuid(),
MyWebsite = new Uri("http://example.com"),
MyDecimalValue = 123.4M,
MyDoubleValue = 456.7,
MyFloatValue = 789.3f,
MyEnum = MyData.eIntEnum.Zero,
};
// Store it serialized with BSON
db.Store(d.MyUID, d);
// simple call Retrieve<T> to get your data deserialized back
var d2 = db.Retrieve<MyData>(id);
What this module automates ?
No-install, ready to use no-sql database
- No tables
- No migration
- no-nothing 'relational'
ConfigurationDB - Configuration storage
Need to store some options or user settings ? This module will cover that
How to use:
// Create a new instance
ConfigurationDB db = new ConfigurationDB("myStuff.db");
// store your data with Key-Category pair
db.SetConfig<string>("Font", "User.UI.FrontPanel", "Arial");
db.SetConfig<Color>("BackColor", "User.UI.FrontPanel", Color.Red);
// retrieve your data with "default option"
var myFont = db.GetConfig<string>("Font", "User.UI.FrontPanel", "Times");
var myBkg = db.GetConfig<Color>("BackColor", "User.UI.FrontPanel", Color.Green);
// remove config
db.RemoveConfig("Font", "User.UI.FrontPanel");
What this module automates ?
This automates various configuration save-set scenarios
Natively supported types:
- All C# "primitive" types
- string
- decimal
- DateTime
- TimeSpan
- Guid
- byte[]
- System.Drawing.Color
Primitive types is all types that type.IsPrimitive == true. Is all types you expect to be primitives: int, float, double, byte, etc...
Check all on this MSDN article
Backup
When a new SqliteDB instance is created a new backup of the database file is made.
As NoSqliteStorage and ConfigurationDB internally uses SqliteDB, they also create a backup
First, the database file is copied and compressed as *.bak.gz
Later backups, the old *.bak.gz
is renamed to *.old.gz
and a new *.bak.gz
is created
See an example with a database named data.db
:
- On first execution, there is no file
- a new empty
data.db
will be created - a new also empty
data.db.bak.gz
is created
- a new empty
- On later execution,
- the backup
data.db.bak.gz
will be renamed todata.db.old.gz
- a new
data.db.bak.gz
will be created fromdata.db
- the backup
Every execution, you have the previous version available as a backup
- To disable backups, you can use the static property as follows:
//this will disable the creation of backups of any posterior instances
SqliteDB.EnabledDatabaseBackup = false;
//this is specially useful when the database reaches a significant size
If you decided to use multiple instances with the same database file, you can avoid multiple backups by reutilizing types
Reutilizing types
If you already have a database and want to stick more stuff to it, you can simply:
- Already have a SqliteDB instance ?
var noSql = NoSqliteStorage.FromDB(mySqliteDB);
var cfg = ConfigurationDB.FromDB(mySqliteDB);
- Already have a NoSqliteStorage instance ?
var db = SqliteDB.FromDB(noSql);
var cfg = ConfigurationDB.FromDB(mySqliteDB);
- Already have a ConfigurationDB instance ?
var db = SqliteDB.FromDB(cfg);
var noSql = NoSqliteStorage.FromDB(cfg);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- Microsoft.Data.Sqlite (>= 5.0.8)
- Newtonsoft.Json.Bson (>= 1.0.2)
- Simple.DatabaseWrapper (>= 1.2.3)
-
.NETFramework 4.7.2
- Microsoft.Data.Sqlite (>= 5.0.8)
- Newtonsoft.Json.Bson (>= 1.0.2)
- Simple.DatabaseWrapper (>= 1.2.3)
-
.NETFramework 4.8
- Microsoft.Data.Sqlite (>= 5.0.8)
- Newtonsoft.Json.Bson (>= 1.0.2)
- Simple.DatabaseWrapper (>= 1.2.3)
-
.NETStandard 2.0
- Microsoft.Data.Sqlite (>= 5.0.8)
- Newtonsoft.Json.Bson (>= 1.0.2)
- Simple.DatabaseWrapper (>= 1.2.3)
-
net5.0
- Microsoft.Data.Sqlite (>= 5.0.8)
- Newtonsoft.Json.Bson (>= 1.0.2)
- Simple.DatabaseWrapper (>= 1.2.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Simple.Sqlite:
Package | Downloads |
---|---|
RafaelEstevam.Simple.Spider.SqliteStorage
Sqlite-based storage engine to the SimpleSpider See examples and documentation on the GitHub page |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.4.2 | 155 | 8/26/2024 | |
1.4.1 | 189 | 6/30/2024 | |
1.4.0 | 127 | 6/30/2024 | |
1.3.2 | 106 | 6/18/2024 | |
1.3.1 | 169 | 5/6/2024 | |
1.2.0 | 152 | 3/26/2024 | |
1.1.0 | 134 | 1/22/2024 | |
1.0.6 | 195 | 11/28/2023 | |
1.0.5 | 421 | 8/26/2023 | |
1.0.4 | 414 | 6/23/2023 | |
1.0.3 | 178 | 5/21/2023 | |
1.0.2 | 274 | 3/9/2023 | |
1.0.1 | 318 | 1/27/2023 | |
1.0.0.4-rc | 149 | 12/20/2022 | |
1.0.0.3-rc | 146 | 11/23/2022 | |
1.0.0.2-rc | 193 | 11/23/2022 | |
1.0.0.1-rc | 146 | 11/16/2022 | |
0.9.1.3 | 392 | 11/23/2022 | |
0.9.1.2 | 372 | 11/23/2022 | |
0.9.1.1 | 366 | 11/2/2022 | |
0.9.1 | 433 | 8/6/2022 | |
0.9.0.1 | 450 | 7/29/2022 | |
0.8.5.4 | 568 | 2/14/2022 | |
0.8.5.3 | 434 | 2/8/2022 | |
0.8.5.2 | 456 | 1/23/2022 | |
0.8.5.1 | 295 | 1/8/2022 | |
0.8.5 | 312 | 1/1/2022 | |
0.8.4.1 | 292 | 12/31/2021 | |
0.8.4 | 1,057 | 11/20/2021 | |
0.8.3 | 775 | 11/7/2021 | |
0.8.2-alpha | 293 | 10/8/2021 | |
0.8.1-alpha | 240 | 8/18/2021 | |
0.8.0-alpha | 400 | 8/11/2021 | |
0.7.4.1 | 411 | 10/15/2021 | |
0.7.4 | 407 | 10/8/2021 | |
0.7.4-alpha | 244 | 8/8/2021 | |
0.7.3 | 432 | 8/3/2021 | |
0.7.2 | 539 | 7/25/2021 | |
0.6.4 | 541 | 5/3/2021 | |
0.6.3 | 437 | 5/1/2021 | |
0.6.2 | 397 | 4/27/2021 | |
0.6.1 | 520 | 3/27/2021 | |
0.5.118 | 453 | 3/14/2021 | |
0.5.100 | 577 | 1/24/2021 | |
0.4.94 | 356 | 1/23/2021 | |
0.4.93 | 408 | 1/23/2021 | |
0.4.90 | 437 | 1/21/2021 | |
0.4.79 | 564 | 1/15/2021 | |
0.4.68 | 485 | 1/6/2021 | |
0.4.63 | 658 | 12/30/2020 | |
0.4.43 | 691 | 12/21/2020 | |
0.4.29 | 563 | 12/19/2020 | |
0.4.24 | 717 | 12/19/2020 | |
0.4.21 | 826 | 12/19/2020 | |
0.1.1 | 486 | 11/5/2020 | |
0.1.0 | 553 | 11/5/2020 |
Paired with commit 955b847
https://github.com/RafaelEstevamReis/SqliteWrapper