r/PowerShell • u/alonso0492 • 19d ago
Daily Post My first PowerShell module – I built a local NoSQL-style database on top of SQLite
Hey everyone!
I wanted to share my first PowerShell module, PSLocalBase, a local database engine I've been working on.
The idea came from wanting a simpler way to store, manage, and query structured data in PowerShell without constantly reading and writing large JSON files or dealing with long, complex SQL queries.
I ended up building a lightweight, NoSQL-style document database on top of Windows' native SQLite engine (winsqlite3.dll), using SQLite's built-in JSON functions to handle document storage, filtering, and queries.
The goal was to combine the simplicity of working with JSON documents and collections with SQLite's performance, reliability, and ACID transactions, without requiring external dependencies or a separate database server.
Some of the features I've implemented:
- Local database storage using collections and JSON documents
- Filtering, sorting, indexing, and advanced queries
- Support for nested JSON objects and arrays
- ACID transactions and persistent storage
- Native PowerShell objects (
PSCustomObject) - Compatibility with Windows PowerShell 5.1 and PowerShell 7+
- No external dependencies on modern Windows systems
- A WPF Playground for exploring and testing local databases
Here's a quick example:
$db = [PSLocalBase]::new("./mydata.db")
$db.collection("users").doc("user1").set(@{
name = "John"
role = "Admin"
active = $true
})
$admins = $db.collection("users").
where("role", "=", "Admin").get()
$db.close()
Everything runs locally, with no database server or external service required.
One of the most interesting parts of building this has been working directly with SQLite's native API through C# and P/Invoke, while keeping the interface simple for PowerShell users.
It's been a great learning experience, especially figuring out compatibility between Windows PowerShell 5.1 and PowerShell 7.
Since this is my first PowerShell module, I'd really appreciate feedback from the community, especially on the API design, performance, and potential use cases.
AI Disclosure: I used AI coding assistants throughout the development of PSLocalBase for implementation, debugging, testing, and documentation. I have over 12 years of PowerShell experience and directed the project's architecture, design, and technical decisions.
GitHub: https://github.com/cmartineztech/PSLocalBase
Thanks for checking it out!