Skip to content

Commit 93cbdab

Browse files
Updates
1 parent bde2e6a commit 93cbdab

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

2 - create table.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <libpq-fe.h>
5+
#include "settings.h"
6+
7+
int main (int argc, char *argv[])
8+
{
9+
// Connect to the database.
10+
PGconn *conn = PQconnectdb("host=" HOSTNAME " dbname=" DATABASE " user=" USERNAME " password=" PASSWORD);
11+
12+
if (PQstatus(conn) == CONNECTION_BAD) {
13+
fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
14+
PQfinish(conn);
15+
exit(0);
16+
}
17+
18+
printf("Connected!\n");
19+
20+
// Close connection.
21+
PQfinish(conn);
22+
printf("Disconnected!\n");
23+
24+
return 0;
25+
}
26+
27+

readme-pt.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ De uso geral:
9494
Códigos:
9595

9696
- <b>1 - connect.c</b>: Realiza a conexão com o servidor.
97+
- <b>2 - create table.c</b>: Cria uma nova tabela no banco de dados.
9798

9899
<br>
99100

@@ -110,10 +111,17 @@ LinkedIn: [Melchisedech Rex](https://www.linkedin.com/in/melchisedech-rex-724152
110111

111112
<br>
112113

114+
: Referências e Links
115+
---
116+
117+
[ZetCode, PostgreSQL programming in C](https://zetcode.com/db/postgresqlc/)
118+
119+
<br>
120+
113121
:scroll: Licença
114122
---
115123

116-
[ BSD-3-Clause license](./license)
124+
[BSD-3-Clause license](./license)
117125

118126
<br><br>
119127

0 commit comments

Comments
 (0)