initial commit
This commit is contained in:
30
vala/PostgresqlDemo.vala
Normal file
30
vala/PostgresqlDemo.vala
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace PostgresqlDemo {
|
||||
using Postgres;
|
||||
|
||||
public static int main (string[] args) {
|
||||
Database conn = set_db_login ("localhost", "5432", "", "", "database", "user", "password");
|
||||
if (conn.get_status () != ConnectionStatus.OK) {
|
||||
stderr.printf ("%s\n", conn.get_error_message ());
|
||||
return 1;
|
||||
}
|
||||
|
||||
Result res = conn.exec ("SELECT * FROM turista");
|
||||
if (res.get_status () != ExecStatus.TUPLES_OK) {
|
||||
stderr.printf ("SELECT failed: %s", conn.get_error_message ());
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < res.get_n_fields (); i++) {
|
||||
stdout.printf ("%-20s", res.get_field_name (i));
|
||||
}
|
||||
stdout.printf ("\n\n");
|
||||
|
||||
for (int i = 0; i < res.get_n_tuples (); i++) {
|
||||
for (int j = 0; j < res.get_n_fields (); j++) {
|
||||
stdout.printf ("%-20s", res.get_value (i, j));
|
||||
}
|
||||
stdout.printf ("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
24
vala/meson.build
Normal file
24
vala/meson.build
Normal file
@@ -0,0 +1,24 @@
|
||||
project('postgresqldemo',
|
||||
['c', 'vala'],
|
||||
version: '1.0.0',
|
||||
license: 'BSD-3',
|
||||
default_options: [
|
||||
'b_ofast=if-release',
|
||||
'b_march_native=if-release',
|
||||
'b_ndebug=if-release'
|
||||
]
|
||||
)
|
||||
add_global_arguments('-DGETTEXT_PACKAGE="sernatur"', language: 'c')
|
||||
|
||||
glib_dep = dependency('glib-2.0')
|
||||
pq_dep = dependency('libpq', version: '>=8.0')
|
||||
|
||||
vala_sources = files('PostgresqlDemo.vala')
|
||||
|
||||
sources = vala_sources
|
||||
|
||||
exe = executable('postgresql_demo',
|
||||
sources,
|
||||
dependencies: [glib_dep, pq_dep],
|
||||
install: false)
|
||||
|
||||
Reference in New Issue
Block a user