SharpHsql.Core 2.0.0

dotnet add package SharpHsql.Core --version 2.0.0
                    
NuGet\Install-Package SharpHsql.Core -Version 2.0.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="SharpHsql.Core" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpHsql.Core" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SharpHsql.Core" />
                    
Project file
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 SharpHsql.Core --version 2.0.0
                    
#r "nuget: SharpHsql.Core, 2.0.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 SharpHsql.Core@2.0.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=SharpHsql.Core&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SharpHsql.Core&version=2.0.0
                    
Install as a Cake Tool

SharpHSQL - Embedded SQL Database for .NET

License NuGet .NET Standard

SharpHSQL is a lightweight, embedded SQL database engine for .NET, ported from the popular Java HSQLDB (HyperSQL Database). It provides a complete SQL database solution with both in-memory and file-based storage options, perfect for applications that need a self-contained database without external dependencies.

✨ Features

  • πŸš€ Lightweight & Embedded - No external database server required, runs entirely within your .NET application
  • πŸ’Ύ Dual Storage Modes - Choose between in-memory (ultra-fast) or file-based (persistent) storage
  • πŸ”’ ACID Compliant - Full transaction support with commit and rollback capabilities
  • πŸ“Š Rich SQL Support - Comprehensive SQL syntax including JOINs, subqueries, aggregates, and more
  • πŸ”Œ Dual API - Native API for advanced control or ADO.NET provider for standard database access
  • ⚑ High Performance - Optimized for speed with efficient indexing and caching
  • 🎯 .NET Standard 2.0 - Compatible with .NET Core, .NET 5+, .NET Framework 4.6.1+, Xamarin, and more
  • πŸ“ 100+ Built-in Functions - Extensive library of math, string, date/time, and system functions

πŸ“¦ Installation

Install via NuGet Package Manager:

dotnet add package SharpHsql.Core

Or via NuGet Package Manager Console:

Install-Package SharpHsql.Core

πŸš€ Quick Start

using System.Data.Hsql;

// Create connection
using var connection = new SharpHsqlConnection("Initial Catalog=mydb;User Id=sa;Pwd=");
connection.Open();

// Create table
using var createCmd = new SharpHsqlCommand(
    "CREATE TABLE Users (Id INT PRIMARY KEY, Name VARCHAR(50), Email VARCHAR(100))", 
    connection);
createCmd.ExecuteNonQuery();

// Insert data
using var insertCmd = new SharpHsqlCommand(
    "INSERT INTO Users VALUES (@id, @name, @email)", 
    connection);
insertCmd.Parameters.Add(new SharpHsqlParameter("@id", DbType.Int32, 0, 
    ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, 1));
insertCmd.Parameters.Add(new SharpHsqlParameter("@name", DbType.String, 0, 
    ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, "John Doe"));
insertCmd.Parameters.Add(new SharpHsqlParameter("@email", DbType.String, 0, 
    ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, "john@example.com"));
insertCmd.ExecuteNonQuery();

// Query data
using var selectCmd = new SharpHsqlCommand("SELECT * FROM Users", connection);
using var reader = selectCmd.ExecuteReader();
while (reader.Read())
{
    Console.WriteLine($"ID: {reader.GetInt32(0)}, Name: {reader.GetString(1)}");
}

Using Native API

using SharpHsql;

// Create database
var database = new Database("mydb");

// Connect
var channel = database.Connect("sa", "");

// Execute commands
var result = database.Execute("CREATE TABLE Products (Id INT, Name VARCHAR(50))", channel);
result = database.Execute("INSERT INTO Products VALUES (1, 'Widget')", channel);
result = database.Execute("SELECT * FROM Products", channel);

// Process results
while (result.Root != null)
{
    var row = result.Root.Data;
    Console.WriteLine($"ID: {row[0]}, Name: {row[1]}");
    result.Root = result.Root.Next;
}

// Disconnect
database.Execute("DISCONNECT", channel);

πŸ’‘ Common Usage Examples

Working with Transactions

using var connection = new SharpHsqlConnection("Initial Catalog=mydb;User Id=sa;Pwd=");
connection.Open();

// Begin transaction
using var transaction = connection.BeginTransaction();

try
{
    var cmd = new SharpHsqlCommand("INSERT INTO Accounts VALUES (1, 1000)", connection);
    cmd.ExecuteNonQuery();
    
    cmd.CommandText = "UPDATE Accounts SET Balance = Balance - 100 WHERE Id = 1";
    cmd.ExecuteNonQuery();
    
    // Commit transaction
    transaction.Commit();
}
catch
{
    // Rollback on error
    transaction.Rollback();
    throw;
}

Using DataAdapter for DataSets

using var connection = new SharpHsqlConnection("Initial Catalog=mydb;User Id=sa;Pwd=");
connection.Open();

var adapter = new SharpHsqlDataAdapter("SELECT * FROM Users", connection);
var dataSet = new DataSet();
adapter.Fill(dataSet);

// Work with DataSet
foreach (DataRow row in dataSet.Tables[0].Rows)
{
    Console.WriteLine(row["Name"]);
}

In-Memory Database

// In-memory database (data lost when application closes)
var database = new Database(".");
var channel = database.Connect("sa", "");

// Create and use tables
database.Execute("CREATE TABLE TempData (Id INT, Value VARCHAR(50))", channel);
database.Execute("INSERT INTO TempData VALUES (1, 'Temporary')", channel);

File-Based Database

// File-based database (data persists to disk)
var database = new Database("./mydata");
var channel = database.Connect("sa", "");

// Data is automatically saved to disk
database.Execute("CREATE TABLE Users (Id INT PRIMARY KEY, Name VARCHAR(50))", channel);
database.Execute("INSERT INTO Users VALUES (1, 'Alice')", channel);

// Data will be available on next application start

πŸ“š Documentation

🎯 Supported SQL Features

Data Definition Language (DDL)

  • CREATE TABLE - Create tables with various data types
  • DROP TABLE - Remove tables
  • ALTER TABLE - Add/remove columns
  • CREATE INDEX - Create indexes for performance

Data Manipulation Language (DML)

  • SELECT - Query data with WHERE, JOIN, GROUP BY, ORDER BY
  • INSERT - Add new rows (with VALUES or SELECT)
  • UPDATE - Modify existing rows
  • DELETE - Remove rows

Advanced Features

  • Joins: INNER JOIN, LEFT OUTER JOIN
  • Subqueries: In SELECT, FROM, and WHERE clauses
  • Set Operations: UNION, UNION ALL, INTERSECT, EXCEPT
  • Aggregates: COUNT, SUM, AVG, MIN, MAX
  • Functions: 100+ built-in functions for math, strings, dates, and more

Data Types

  • Numeric: TINYINT, SMALLINT, INTEGER, BIGINT, DECIMAL, DOUBLE, FLOAT
  • String: CHAR, VARCHAR, LONGVARCHAR
  • Binary: BINARY, VARBINARY, LONGVARBINARY
  • Date/Time: DATE, TIME, TIMESTAMP
  • Other: BIT (boolean), NULL

πŸ”§ Building from Source

Prerequisites

  • .NET SDK 6.0 or higher
  • Git

Build Steps

# Clone the repository
git clone https://github.com/andresvettori/sharphsql.git
cd sharphsql/sourceCode/src/Main/Source/SharpHSQL

# Build the solution
./build.ps1

# Build and create NuGet package
./build.ps1 -CreatePackage

# Build, run tests, and create package
./build.ps1 -Configuration Release -CreatePackage

The build script uses GitVersion for automatic semantic versioning based on your Git history.

πŸ§ͺ Running Tests

dotnet test SharpHSQL.Tests/SharpHSQL.Tests.csproj

🀝 Contributing

Contributions are welcome! Please read our Contributing Guidelines for details on how to submit pull requests, report issues, and contribute to the project.

πŸ“„ License

SharpHSQL is licensed under the BSD 3-Clause License. See LICENSE file for details.

This project is based on HypersonicSQL, originally developed by Thomas Mueller.

🌟 Acknowledgments

  • Original HSQLDB Java project: http://hsqldb.org/
  • C# port contributors: Mark Tutt, AndrΓ©s G Vettori, and community contributors

πŸ“ž Support

πŸ—ΊοΈ Roadmap

  • .NET 8.0 optimizations
  • Additional SQL functions
  • Performance improvements
  • Enhanced documentation and examples
  • Community-requested features

Made with ❀️ by Andrés G Vettori and contributors

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.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 was computed.  net48 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 118 3/28/2026

See CHANGELOG.md for release notes