Potato.SQLite
1.1.0
dotnet add package Potato.SQLite --version 1.1.0
NuGet\Install-Package Potato.SQLite -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Potato.SQLite" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Potato.SQLite" Version="1.1.0" />
<PackageReference Include="Potato.SQLite" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Potato.SQLite --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Potato.SQLite, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Potato.SQLite@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Potato.SQLite&version=1.1.0
#tool nuget:?package=Potato.SQLite&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Potato.SQLite
The Potato.SQLite
library is a helper class designed to simplify interactions with SQLite databases in .NET applications.
It supports database initialization, data manipulation (CRUD operations), and utility functions for SQLite.
Features
- Database Initialization: Automatically creates the SQLite database file if it does not exist.
- CRUD Operations: Provides asynchronous methods to insert, update, delete, and query data.
- Parameterized Queries: Protects against SQL injection.
- Flexible Initialization: Allows for optional configuration of base image URIs.
Installation
- Add the
Potato.SQLite
class to your project. - Ensure you have the
System.Data.SQLite
NuGet package installed.
dotnet add package System.Data.SQLite
Usage
1. Initialize the Helper Class
using Potato.SQLite;
// With base image URI
var helper = new Helper("C:\\databases", "example.db", new Uri("http://example.com/images"));
// Without base image URI
var helperWithoutImage = new Helper("C:\\databases", "example.db");
2. Insert Data
Insert a Collection of Rows
var data = new List<Dictionary<string, object>>
{
new Dictionary<string, object> { { "Name", "Potato" }, { "Type", "Vegetable" } },
new Dictionary<string, object> { { "Name", "Tomato" }, { "Type", "Fruit" } },
};
await helper.InsertDataAsync("Products", data);
Insert Data and Get the Last Inserted ID
int lastId = await helper.InsertReturnDataAsync("Products", data);
Console.WriteLine($"Last inserted ID: {lastId}");
3. Query Data
Read All Rows from a Table
var rows = await helper.ReadAllDataAsync("Products");
foreach (var row in rows)
{
Console.WriteLine(string.Join(", ", row.Select(kvp => $"{kvp.Key}: {kvp.Value}")));
}
Read Data with Conditions
var conditions = new Dictionary<string, object> { { "Type", "Vegetable" } };
var rowsWithConditions = await helper.ReadDataAsync("Products", conditions);
4. Update Data
Update Rows with Specific Conditions
var updatedValues = new Dictionary<string, object> { { "Name", "Sweet Potato" } };
var conditions = new Dictionary<string, object> { { "Name", "Potato" } };
await helper.UpdateDataAsync("Products", updatedValues, conditions);
5. Delete Data
var conditions = new Dictionary<string, object> { { "Name", "Potato" } };
await helper.DeleteDataAsync("Products", conditions);
Notes
- Connection Management: The library manages database connections internally. You do not need to explicitly open or close connections.
- Thread Safety: Ensure proper thread synchronization if using the library in multi-threaded applications.
- SQL Injection Prevention: Always use parameterized queries for safe interactions.
Contributing
Contributions are welcome! If you encounter a bug or want to add new features, feel free to submit a pull request or file an issue.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- System.Data.SQLite (>= 1.0.119)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.1.0 | 128 | 11/28/2024 |