GitHub - melchisedech333/c-postgresql: :elephant: Introductory examples for people who want to use PostgreSQL with the C language. In the examples, the most basic operations to manage the database were covered, namely: connecting, creating tables, inserting records, selecting data, updating and deleting records.
Language: PT-BR
The purpose of the codes in this repository is to provide a set of code examples for anyone starting to use PostgreSQL with the C language.
If my code has helped you, please consider sponsoring me ๐
๐ Table of Contents
โญ General notions
To install PostgreSQL on Linux (Debian/Ubuntu based distributions) you can run the commands below.
sudo apt install postgresql postgresql-contrib sudo apt install libpq-dev
Connect to server:
When accessing the server, you can use these commands below to manage it.
\l Lists the databases.
\c DB_NAME Connects to an existing database.
\dt Lists existing tables.
\q Log out of the server.
๐ Description of files
General use:
- build.sh: Generate executables (compile).
- settings.h: Header containing PostgreSQL server settings.
Codes:
- 1 - connect.c: Makes the connection to the server.
- 2 - create table.c: Creates and deletes a table in the database.
- 3 - insert item.c: Insert records into a table.
- 4 - select all.c: Selects records from a table.
- 5 - delete.c: Delete records.
- 6 - update.c: Update records.
๐จ Compiling the codes
To compile the codes, just run the build.sh script, specifying in its parameters the name of the file you want to compile, as in the example below.
./build.sh "1 - connect.c"The compiled file is always saved with the name app-test, so just run it to run the tests.
๐ References and Links
ZetCode, PostgreSQL programming in C
๐ Author
Sponsor: melchisedech333
Twitter: Melchisedech333
LinkedIn: Melchisedech Rex
Blog: melchisedech333.github.io

