{"id":13543954,"url":"https://github.com/rluba/jai-postgres","last_synced_at":"2025-04-02T13:31:22.937Z","repository":{"id":53910825,"uuid":"313334177","full_name":"rluba/jai-postgres","owner":"rluba","description":"Mimimal Postgresql client for Jai","archived":false,"fork":false,"pushed_at":"2025-02-24T16:48:32.000Z","size":107,"stargazers_count":15,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-24T17:46:35.749Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rluba.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-16T14:50:04.000Z","updated_at":"2025-02-24T16:48:37.000Z","dependencies_parsed_at":"2023-02-01T06:15:15.544Z","dependency_job_id":"2dcf8c19-0b09-48f8-a133-f2f9562688d4","html_url":"https://github.com/rluba/jai-postgres","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Fjai-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Fjai-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Fjai-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rluba%2Fjai-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rluba","download_url":"https://codeload.github.com/rluba/jai-postgres/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246823717,"owners_count":20839768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T11:00:39.545Z","updated_at":"2025-04-02T13:31:17.928Z","avatar_url":"https://github.com/rluba.png","language":null,"funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Mimimal Postgresql client for Jai\n\nThis module contains `libpq` bindings as well as some higher-level functions for…\n* … connecting to a Postgresql database,\n* … executing parameterized queries and\n* … optionally parsing the results into a typed array.\n\nIt only supports synchronous execution for now.\n\n## Usage\n\nFirst connect to a Postgresql instance using a connection uri string:\n\n```Jai\nconnection_str := \"postgres://\u003cusername\u003e:\u003cpassword\u003e@\u003chost\u003e:\u003cport\u003e/\u003cdb\u003e\";\nconn, success := connect(connection_str);\ndefer disconnect(conn);\n```\n\nThen use `conn` to execute statements…\n\n```Jai\n// Restrict schema access\nsuccess = execute(conn, \"SELECT pg_catalog.set_config('search_path', 'public', false)\");\n```\n\n… or execute a query and automatically parse the result into an array of any given type:\n\n```Jai \nquery :: #string END\n\tSELECT * FROM tourist_attractions\n\tWHERE city = $1 AND price \u003c $2 AND min_age \u003c $3\n\tORDER BY name\nEND\n\nAttraction :: struct {\n\tname: string;\n\tcity: string;\n\tprice: string; // Numerics are parsed into strings\n\tmin_age: int;\n\tis_open: bool;\n}\n\n// Query parameters can be passed as variadic args after `query`:\ncity := \"Vienna\";\nprice := 50;\nmin_age := 18;\nattractions, success = execute(conn, Attraction, query, city, price, min_age);\n```\n\nBy default, `execute` fails if the result contains a column that has no corresponding member in the struct type you passed.\nYou can pass `ignore_unknown = true` to `execute(…)` to ignore unknown columns instead.\n\nIf your struct type contains members that aren’t present in the result (or are null), they will be left at their default values.\n\n## Memory model\n\nYou’re responsible for freeing everything (including strings) in the result array.\nUsing a Pool allocator around your `execute` calls might be a good idea.\n\n## Supported query parameter types\n\n* All integer types\n* `float` and `float64`\n* `string`\n\n## Supported return value column types\n\n* `INT2`, `INT4`, `INT8`\n* `FLOAT4`, `FLOAT8`\n* `NUMERIC` (currently only parsed into `string` fields)\n* `BOOL`\n* `CHAR`, `BPCHAR`, `VARCHAR`, `NAME`, `TEXT`\n* `DATE`, `TIMESTAMP`, `TIMESTAMPTZ`\n* `BYTEA`\n* `OID`\n* Custom enum types (`CREATE TYPE … AS ENUM`), which can be parsed into `string` or `enum` member fields.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frluba%2Fjai-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frluba%2Fjai-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frluba%2Fjai-postgres/lists"}