PotatoSQLite 1.1.0
The PotatoSQLite package has been deprecated and is no longer maintained. It has been renamed to Potato.SQLite for better clarity and naming consistency. Please migrate to Potato.SQLite to continue receiving updates and support. Thank you for your understanding.
dotnet add package PotatoSQLite --version 1.1.0
NuGet\Install-Package PotatoSQLite -Version 1.1.0
<PackageReference Include="PotatoSQLite" Version="1.1.0" />
<PackageVersion Include="PotatoSQLite" Version="1.1.0" />
<PackageReference Include="PotatoSQLite" />
paket add PotatoSQLite --version 1.1.0
#r "nuget: PotatoSQLite, 1.1.0"
#:package PotatoSQLite@1.1.0
#addin nuget:?package=PotatoSQLite&version=1.1.0
#tool nuget:?package=PotatoSQLite&version=1.1.0
PotatoSQLite Library - README
The PotatoSQLite
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
PotatoSQLite
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 PotatoSQLite;
// 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. |
-
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 | 144 | 11/23/2024 |