diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2008-07-07 18:49:25 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2008-07-07 18:49:25 +0200 |
commit | ea2560808d3665c51b294a5f91d1daa6e5030f26 (patch) | |
tree | 01f4e84b47b953912bfb12c40af19d3db3f8adcb /tests/psql | |
parent | fe81409fff271191948e7d87ec6b3afb3b240dcf (diff) | |
download | crawler-ea2560808d3665c51b294a5f91d1daa6e5030f26.tar.gz crawler-ea2560808d3665c51b294a5f91d1daa6e5030f26.tar.bz2 |
added Postgresql libpqpp tests
Diffstat (limited to 'tests/psql')
-rw-r--r-- | tests/psql/GNUmakefile | 29 | ||||
-rw-r--r-- | tests/psql/README | 1 | ||||
-rw-r--r-- | tests/psql/test1.cpp | 42 |
3 files changed, 72 insertions, 0 deletions
diff --git a/tests/psql/GNUmakefile b/tests/psql/GNUmakefile new file mode 100644 index 0000000..754895f --- /dev/null +++ b/tests/psql/GNUmakefile @@ -0,0 +1,29 @@ +TOPDIR = ../.. + +SUBDIRS = + +INCLUDE_DIRS = -I. -I$(TOPDIR) -I/usr/include/pqxx + +LDFLAGS_DIR = \ + -L/usr/lib + +LIBS_DIR = \ + -lpqxx -lpq + +CPP_BINS = \ + test1$(EXE) + +OBJS = + +-include $(TOPDIR)/makefiles/sub.mk + +local_all: + +local_clean: + +local_distclean: + +local_test: $(CPP_BINS) + @echo "libpqxx simple test.." + ./test1 +
\ No newline at end of file diff --git a/tests/psql/README b/tests/psql/README new file mode 100644 index 0000000..51987a7 --- /dev/null +++ b/tests/psql/README @@ -0,0 +1 @@ +test1 - using the newest libpqxx diff --git a/tests/psql/test1.cpp b/tests/psql/test1.cpp new file mode 100644 index 0000000..5d4e06f --- /dev/null +++ b/tests/psql/test1.cpp @@ -0,0 +1,42 @@ +#include <iostream> +#include <sstream> +#include <stdio.h> + +#include "pqxx" + +using namespace pqxx; +using namespace PGSTD; +using namespace std; + +int main( ) { + connection c( "dbname=test" ); + + //c.trace( stdout ); + + cout << "Conntected to database." << endl + << "Backend protocol version: " << c.server_version( ) << endl + << "Protocol version: " << c.protocol_version( ) << endl + << "Server PID: " << c.backendpid( ) << endl + << "Prepared Statements: " << c.supports( c.cap_prepared_statements ) << endl; + + work t( c, "test transaction" ); + + t.exec( "create table test( a integer, b integer)" ); + for( unsigned int i = 0; i < 1000; i++ ) { + ostringstream sql; + sql << "insert into test values( '" << i << "', '" << i << "' )"; + t.exec( sql.str( ) ); + } + + result r( t.exec( "select * from test" ) ); + cout << "a\tb" << endl; + for( result::size_type i = 0; i < r.size( ); i++ ) { + cout << r[i]["a"] << "\t" << r[i]["b"] << endl; + } + + t.exec( "drop table test" ); + + t.commit( ); + + return 0; +} |