gnomemm r1716 - in libgdamm/branches/libgdamm-3-0: . examples/simple_iter
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1716 - in libgdamm/branches/libgdamm-3-0: . examples/simple_iter
- Date: Tue, 30 Sep 2008 11:44:55 +0000 (UTC)
Author: murrayc
Date: Tue Sep 30 11:44:55 2008
New Revision: 1716
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1716&view=rev
Log:
Increased version
Modified:
libgdamm/branches/libgdamm-3-0/ChangeLog
libgdamm/branches/libgdamm-3-0/NEWS
libgdamm/branches/libgdamm-3-0/configure.in
libgdamm/branches/libgdamm-3-0/examples/simple_iter/main.cc
Modified: libgdamm/branches/libgdamm-3-0/NEWS
==============================================================================
--- libgdamm/branches/libgdamm-3-0/NEWS (original)
+++ libgdamm/branches/libgdamm-3-0/NEWS Tue Sep 30 11:44:55 2008
@@ -1,3 +1,8 @@
+3.0.1: (stable)
+
+* Connection::get_schema(): Fix a reference counting problem.
+ (Murray Cumming)
+
3.0.0: (stable)
* DictConstraint: Removed fkey_set_fields().
Modified: libgdamm/branches/libgdamm-3-0/configure.in
==============================================================================
--- libgdamm/branches/libgdamm-3-0/configure.in (original)
+++ libgdamm/branches/libgdamm-3-0/configure.in Tue Sep 30 11:44:55 2008
@@ -17,7 +17,7 @@
#We use pushdef here because we can't use shell variables before AC_INIT, but we want to use a variable with AC_INIT:
pushdef([LIBGDAMM_MAJOR_VERSION], [3])
pushdef([LIBGDAMM_MINOR_VERSION], [0])
-pushdef([LIBGDAMM_MICRO_VERSION], [0])
+pushdef([LIBGDAMM_MICRO_VERSION], [1])
pushdef([LIBGDAMM_EXTRA_VERSION], [])
pushdef([LIBGDAMM_VERSION], LIBGDAMM_MAJOR_VERSION.LIBGDAMM_MINOR_VERSION.LIBGDAMM_MICRO_VERSION[]LIBGDAMM_EXTRA_VERSION)
AC_INIT([libgdamm], LIBGDAMM_VERSION, [gtkmm-list gnome org])
Modified: libgdamm/branches/libgdamm-3-0/examples/simple_iter/main.cc
==============================================================================
--- libgdamm/branches/libgdamm-3-0/examples/simple_iter/main.cc (original)
+++ libgdamm/branches/libgdamm-3-0/examples/simple_iter/main.cc Tue Sep 30 11:44:55 2008
@@ -22,6 +22,73 @@
#include <libgdamm.h>
#include <iostream>
+Glib::RefPtr<Gnome::Gda::Connection> gda_connection;
+
+void do_sql(const Glib::ustring& query)
+{
+ //Get data from a table:
+ Gnome::Gda::Command command(query);
+
+ //Specify a parameter, to request an iter-only model:
+ Glib::RefPtr<Gnome::Gda::ParameterList> params = Gnome::Gda::ParameterList::create();
+ Gnome::Gda::Value value;
+ value.set(true);
+ params->add_parameter("ITER_MODEL_ONLY", value);
+
+ Glib::RefPtr<Gnome::Gda::DataModel> data_model;
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ data_model = gda_connection->execute_select_command(command, params);
+ }
+ catch(const Glib::Exception& ex)
+ {
+ std::cerr << "Exception caught: " << ex.what() << std::endl;
+ }
+#else
+ data_model = gda_connection->execute_select_command(command, params, error);
+ if(error.get())
+ {
+ std::cerr << "Exception caught: " << error->what() << std::endl;
+ }
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ if(!data_model)
+ {
+ std::cout << "command execution failed." << std::endl;
+ }
+ else if(data_model)
+ {
+ const int columns = data_model->get_n_columns();
+ std::cout << " Number of columns: " << columns << std::endl;
+
+ for(int i = 0; i < columns; ++i)
+ {
+ std::cout << " column " << i << ": " << data_model->get_column_title(i);
+
+ //Find out whether it's the primary key:
+ //TODO: This does not seem to work.
+ const Glib::RefPtr<Gnome::Gda::Column> field = data_model->describe_column(i);
+ const bool is_primary_key = field->get_primary_key();
+ if(is_primary_key)
+ std:: cout << " (primary key)";
+
+ std::cout << std::endl;
+ }
+
+ std::cout << std::endl;
+
+ Glib::RefPtr<Gnome::Gda::DataModelIter> iter = data_model->create_iter();
+ int row = 0;
+ while(iter->move_next()) //The first move_next() makes the iter point to the first row.
+ {
+
+ }
+
+ std::cout << " Number of rows: " << row << std::endl;
+
+ }
+}
int main (int argc, char** argv)
{
@@ -38,13 +105,12 @@
const gchar* connection_provider = "PostgreSQL";
const gchar* connection_host = "localhost";
- const gchar* connection_table = "glom_musiccollection217";
+ const gchar* connection_table = "importtest";
const Glib::ustring connection_string = Glib::ustring("PORT=5433;HOST=") + connection_host + ";DB_NAME=" + connection_table;
const gchar* connection_username = "murrayc";
- const gchar* connection_password = "murraycpw";
+ const gchar* connection_password = "luftballons";
- Glib::RefPtr<Gnome::Gda::Connection> gda_connection;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
@@ -66,90 +132,8 @@
std::cerr << "Error: Could not open connection to " << connection_string << std::endl;
else
{
- //Open database:
- //gda_connection->change_database("murrayc");
-
- //Get data from a table:
- Gnome::Gda::Command command("SELECT artist_id, picture FROM artists");
-
- //Specify a parameter, to request an iter-only model:
- Glib::RefPtr<Gnome::Gda::ParameterList> params = Gnome::Gda::ParameterList::create();
- Gnome::Gda::Value value;
- value.set(true);
- params->add_parameter("ITER_MODEL_ONLY", value);
-
- Glib::RefPtr<Gnome::Gda::DataModel> data_model;
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- try
- {
- data_model = gda_connection->execute_select_command(command, params);
- }
- catch(const Glib::Exception& ex)
- {
- std::cerr << "Exception caught: " << ex.what() << std::endl;
- }
-#else
- data_model = gda_connection->execute_select_command(command, params, error);
- if(error.get())
- {
- std::cerr << "Exception caught: " << error->what() << std::endl;
- }
-#endif //GLIBMM_EXCEPTIONS_ENABLED
-
- if(!data_model)
- {
- std::cout << "command execution failed." << std::endl;
- }
- else if(data_model)
- {
- const int columns = data_model->get_n_columns();
- std::cout << " Number of columns: " << columns << std::endl;
-
- for(int i = 0; i < columns; ++i)
- {
- std::cout << " column " << i << ": " << data_model->get_column_title(i);
-
- //Find out whether it's the primary key:
- //TODO: This does not seem to work.
- const Glib::RefPtr<Gnome::Gda::Column> field = data_model->describe_column(i);
- const bool is_primary_key = field->get_primary_key();
- if(is_primary_key)
- std:: cout << " (primary key)";
-
- std::cout << std::endl;
- }
-
- std::cout << std::endl;
-
- Glib::RefPtr<Gnome::Gda::DataModelIter> iter = data_model->create_iter();
- int row = 0;
- while(iter->move_next()) //The first move_next() makes the iter point to the first row.
- {
- std::cout << " row " << row << ": ";
-
- for(int col = 0; col < columns; ++col)
- {
- Glib::RefPtr<Gnome::Gda::Parameter> param = iter->get_param_for_column(col);
- Gnome::Gda::Value value_name = param->get_value();
-
- std::string str = value_name.to_string();
- try
- {
- std::cout << str << ", ";
- }
- catch(const Glib::ConvertError& ex)
- {
- std::cout << "(INVALID UTF-8), ";
- }
- }
-
- std::cout << std::endl;
- ++row;
- }
-
- std::cout << " Number of rows: " << row << std::endl;
-
- }
+ do_sql("SELECT \"album\".\"id\", \"album\".\"artist\", \"album\".\"name\" FROM \"album\" LIMIT 50000");
+ do_sql("SELECT * FROM \"track\" LIMIT 50000");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]