rajeshpillai/zig-c-postgres
Connect to postgres using C headers with Zig
Using postgres c library with zig
Zig Versions
I have hardcoded the include path of libpq-fe.h
const postgres_include_path = "/usr/include/postgresql/";
const c = @cImport({
@cInclude(postgres_include_path ++ "libpq-fe.h");
});
Update the connection string in demo/demo.zig
const connection_string = "host=localhost port=5432 dbname=portal_cms_dev user=postgres password=root123";
If you want to know where the libpq-fe.h is installed you can run the below command assuming postgres and related dependencies are installed.
pkg-config --cflags libpq
URL: https://www.postgresql.org/docs/current/libpq-build.html
Please change this to work for your. Will try to remove hardcoding.
zig run demo.zig -lc -lpq
zig run orm-demo.zig -lc -lpq