Giorgi / SharpPostgres
PublicA proof-of-concept toolkit for building PostgreSQL extensions in C# with Native AOT
SharpPostgres is a proof-of-concept toolkit that lets developers write PostgreSQL database extensions using C# with Native AOT compilation. Instead of learning C or Rust, developers can write simple methods with attributes, and a source generator automatically creates all the technical code needed for PostgreSQL to call those functions. The toolkit supports scalar functions, set-returning functions, composite types, and error handling that integrates with PostgreSQL's native error system. A real-world example (JSON Schema validation) demonstrates practical use.
How It Works
You've heard about writing PostgreSQL extensions in C#, and you're curious if it's really possible to build database functions without learning C or Rust.
You add a method to your C# project and mark it with a special attribute. It looks just like a regular method—just add one line above it.
A source generator scans your code and automatically creates all the complex plumbing needed for PostgreSQL to call your function—no manual boilerplate required.
Your C# code compiles down to a native library that PostgreSQL can load directly, like any other database extension.
Validate JSON data against schemas directly in your database, with built-in caching for performance
Write functions that transform data, split text, generate series, or perform any custom logic
Create functions that return entire result sets, like generating test data or pivoting tables
With a simple command, your extension becomes part of your database. Now you can call your custom functions from any SQL query.
Your custom logic now runs inside PostgreSQL, accessible to any application that connects to your database—no matter what language they use.
Star Growth
Repurpose is a Pro feature
Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.
Unlock RepurposeSimilar repos coming soon.