https://github.com/aarroyoc/postgresql-prolog Skip to content Sign up * Why GitHub? Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Issues - + Integrations - + GitHub Sponsors - + Customer stories- * Team * Enterprise * Explore + Explore GitHub - Learn and contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing Plans - + Compare plans - + Contact Sales - + Education - [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} aarroyoc / postgresql-prolog Public * Notifications * Star 33 * Fork 0 A Prolog library to connect to PostgreSQL databases Apache-2.0 License 33 stars 0 forks Star Notifications * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 1 branch 0 tags Code Latest commit @aarroyoc aarroyoc PostgreSQL Prolog 1.0 ... 0afdfeb Sep 26, 2021 PostgreSQL Prolog 1.0 0afdfeb Git stats * 2 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows PostgreSQL Prolog 1.0 Sep 26, 2021 LICENSE Initial commit Sep 26, 2021 README.md PostgreSQL Prolog 1.0 Sep 26, 2021 messages.pl PostgreSQL Prolog 1.0 Sep 26, 2021 postgresql.pl PostgreSQL Prolog 1.0 Sep 26, 2021 tester.lgt PostgreSQL Prolog 1.0 Sep 26, 2021 tests.lgt PostgreSQL Prolog 1.0 Sep 26, 2021 types.pl PostgreSQL Prolog 1.0 Sep 26, 2021 View code postgresql-prolog Compatible systems Installation Usage Examples README.md postgresql-prolog A Prolog library to connect to PostgreSQL databases Compatible systems * Scryer Prolog Installation The library itself are just three Prolog files (postgresql.pl, messages.pl and types.pl). They need to be in the same folder. An easy way to install this library in your project is copying that files. Other way is using Git submodules to get this whole folder, and load the postgresql.pl file from there. git submodule add https://github.com/aarroyoc/postgresql-prolog postgresql Usage The library provides two predicates: connect/6 and query/3. connect(+User, +Password, +Host, +Port, +Database, -Connection) Connects to a PostgreSQL server and tries to authenticate using password scheme. This is the only authentication method supported right now. Please, note that this auth method is not the default in some PostgreSQL setups, you changes are needed. If you're running PostgreSQL in Docker, you need to set the environment variable POSTGRES_HOST_AUTH_METHOD to password. query(+Connection, +Query, -Result) Executes a SQL query over a connection. Result can be: * ok * error(ErrorString) * data(ColumnDescription, Rows) ok is returned if the query doesn't output a table (INSERT, UPDATE, DELETE, CREATE TABLE, ...) and succeeds. error(ErrorString) is returned if an error is found. data(ColumnDescription, Rows) is returned when a query outputs a table (SELECT). ColumnDescription is a list of column names and Rows is a list of a list of each cell value. Examples :- use_module('postgresql'). test :- connect("postgres", "postgres", '127.0.0.1', 5432, "postgres", Connection), query(Connection, "DROP TABLE IF EXISTS test_table", ok), query(Connection, "CREATE TABLE test_table (id serial, name text)", ok), query(Connection, "INSERT INTO test_table (name) VALUES ('test')", ok), query(Connection, "SELECT * FROM test_table", Rows), Rows = data(["id", "name"], [["1", "test"]]), query(Connection, "UPDATE test_table SET name = 'test2' WHERE id = 1", ok), query(Connection, "SELECT * FROM test_table", Rows2), data(["id", "name"], [["1", "test2"]]). About A Prolog library to connect to PostgreSQL databases Resources Readme License Apache-2.0 License Releases No releases published Packages 0 No packages published Languages * Prolog 78.2% * Logtalk 21.8% * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.