{"id":17224359,"url":"https://github.com/disinterpreter/ml_pgsql","last_synced_at":"2025-04-14T00:37:58.270Z","repository":{"id":55077242,"uuid":"327684047","full_name":"Disinterpreter/ml_pgsql","owner":"Disinterpreter","description":null,"archived":false,"fork":false,"pushed_at":"2021-01-16T09:12:56.000Z","size":1881,"stargazers_count":9,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T14:52:24.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Disinterpreter.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}},"created_at":"2021-01-07T17:43:49.000Z","updated_at":"2025-03-24T18:01:57.000Z","dependencies_parsed_at":"2022-08-14T11:20:27.837Z","dependency_job_id":null,"html_url":"https://github.com/Disinterpreter/ml_pgsql","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Disinterpreter%2Fml_pgsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Disinterpreter%2Fml_pgsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Disinterpreter%2Fml_pgsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Disinterpreter%2Fml_pgsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Disinterpreter","download_url":"https://codeload.github.com/Disinterpreter/ml_pgsql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248803811,"owners_count":21164122,"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-10-15T04:10:52.550Z","updated_at":"2025-04-14T00:37:58.226Z","avatar_url":"https://github.com/Disinterpreter.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Postgre.SQL module for MTA-SA\n\n# Description\t\nSimple module for MTA that provides Postgre.SQL client API.\u003cbr\u003e\t\nI accept any support regarding the module development. Feel free to make PRs and Issues.\t\n\n# Installation\t\nInformation about **Installation** provided on the **[Releases](https://github.com/Disinterpreter/ml_pgsql/releases)** page.\n\n# Functions\t\n## pg_conn function\n### Syntax\n```lua\nuserdata pg_conn(string connection)\n```\n### Description\nAttempts to make connection with your Postgre.SQL server.\n\n### Parameters\n`string connection` - connection query string.\u003cbr\u003e\nMight look like:\n* `postgresql://USER:PASSWORD@IP:PORT/dbname?connect_timeout=3`\n* `hostaddr=IP port=5432 dbname=DBNAME user=USERNAME password=PASSWORD`\n\n### Return value\nIf the connection attempt is successfull, the function returns **connection handle**.\u003cbr\u003e\nOn the failure, the function returns 2 values:\n* `false` (bool)\n* `Error message` (string)\n\n### Example of usage\n```lua\nlocal conn,err = pg_conn(\"postgresql://user:123qwe@127.0.03:5432/mydb?connect_timeout=3\");\t\nif (err ~= nil) then\n   print(err)\n   return 1;\nend\n```\n\n## pg_query function\n### Syntax\n```lua\nuserdata pg_query(userdata connection, string query)\n```\n### Description\nSends query to the Postgre.SQL server with provided data. String escaping supports as well.\n\n### Parameters\n`userdata connection` - connection handle (see pg_conn).\u003cbr\u003e\n`string query` - query to send to the Postgre.SQL server.\n\n### Return value\nIf query was sent successfully, the function returns **userdata with the query result handle**.\u003cbr\u003e\nOn the failure, the function returns 2 values:\n* `false` (bool)\n* `Error message` (string)\n\n### Example of usage\n```lua\nlocal query,qerr = pg_query(conn, \"SELECT $1 as a, $2 as b\", -67, 2)\nif (query == false)  then\n    iprint(qerr)\nend\t\n```\n## pg_poll function\n### Syntax\n```lua\ntable pg_poll(userdata query)\t\n```\n### Description\nGets the data from the query result handle.\n\n### Parameters\n`userdata query` - query result handle (see pg_query).\n\n### Return value\nOn the success, the function returns a table.\u003cbr\u003e\nOn the failure, the function returns 1 value:\n* `false` (bool)\n\n### Example of usage\n```lua\nlocal query,qerr = pg_query(conn, \"SELECT $1 as a, $2 as b\", -67, 2)\nif (query == false)  then\n    iprint(qerr)\nend\niprint(pg_poll(query));\n```\n\n## pg_free function\n### Syntax\n```lua\nbool pg_free(userdata query)\n```\n\n### Description\nFrees memory after executing the query (in case it didn't happen before).\n\n### Parameters\n`userdata query` - query result handle (see pg_query).\n\n### Return value\nIf the query result handle is valid, the function returns `true` (bool).\u003cbr\u003e\nOtherwise the function returns `false` (bool).\n\n### Example of usage\n```lua\nlocal query,qerr = pg_query(conn, \"SELECT $1 as a, $2 as b\", -67, 2)\npg_free(query)\n```\n\n## pg_exec function\n### Syntax\n```lua\nbool pg_exec(userdata connection, string query)\n```\n\n### Description\nSends query to the Postgre.SQL server, except it doesn't return any data like pg_query.\n\n### Parameters\n`userdata connection` - connection handle (see pg_conn).\u003cbr\u003e\n`string query` - query to send to the Postgre.SQL server.\n\n### Return value\nIf query was successfully sent, the function returns userdata with the query result handle.\u003cbr\u003e\nOn the failure, the function returns 2 values:\n* `false` (bool)\n* `Error message` (string)\n\n### Example of usage\n```lua\nlocal exec = pg_exec(conn, \"INSERT INTO users (name, password, money) VALUES ($1,$2,$3)\", \"a man\", \"mypasswd\", \"13\");\niprint(exec);\n```\n\n## pg_close function\n### Syntax\n```lua\nbool pg_close(userdata connection)\n```\n\n### Description\nCloses connection with the Posgre.SQL server.\n\n### Parameters\n`userdata connection` - connection handle (see pg_conn).\n\n### Return value\nIf connection was closed successfully, the function returns `true` (bool).\u003cbr\u003e\nOn the failure, the function returns `false` (bool).\n\n### Example of usage\n```lua\nlocal conn,err = pg_conn(\"postgresql://user:123qwe@127.0.03:5432/mydb?connect_timeout=3\");\n\n... (some code here)\n\npg_close(conn);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisinterpreter%2Fml_pgsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdisinterpreter%2Fml_pgsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisinterpreter%2Fml_pgsql/lists"}