File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ De uso geral:
94
94
Códigos:
95
95
96
96
- <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.
97
98
98
99
<br >
99
100
@@ -110,10 +111,17 @@ LinkedIn: [Melchisedech Rex](https://www.linkedin.com/in/melchisedech-rex-724152
110
111
111
112
<br >
112
113
114
+ : Referências e Links
115
+ ---
116
+
117
+ [ ZetCode, PostgreSQL programming in C] ( https://zetcode.com/db/postgresqlc/ )
118
+
119
+ <br >
120
+
113
121
:scroll : Licença
114
122
---
115
123
116
- [ BSD-3-Clause license] ( ./license )
124
+ [ BSD-3-Clause license] ( ./license )
117
125
118
126
<br ><br >
119
127
You can’t perform that action at this time.
0 commit comments