[pygda] Partial port to introspection.



commit 3bd6511248ae4e6291935275c66063220cef28a0
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 11 13:54:15 2011 +0100

    Partial port to introspection.

 examples/gda/select.py |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/examples/gda/select.py b/examples/gda/select.py
index b9061c6..06d052c 100755
--- a/examples/gda/select.py
+++ b/examples/gda/select.py
@@ -17,47 +17,47 @@
 # *
 # */
 
-import pygtk; pygtk.require("2.0")
-import gda
+from gi.repository import Gda
 
 def main ():
 
     data_source_name = "datasource_pygda_example_select11";
 
-    #TODO: This should be gda.Config.find_data_source().
-    data_source = gda.config_find_data_source(data_source_name);
+    #TODO: This should be Gda.Config.find_data_source().
+    gdaconfig = Gda.Config.get();
+    data_source = gdaconfig.get_dsn_info(data_source_name);
     if not data_source:
         print "Creating the DataSource, because it does not exist yet.";
 
         # Create it if it does not exist already:
-        data_source = gda.DataSourceInfo();
+        data_source = Gda.DsnInfo();
         data_source.name = data_source_name;
         data_source.username = "murrayc";
-        data_source.password = "murraycpw";      
+        data_source.password = "murraycpw";
         data_source.description = "Data Source for libgdamm simple example.";
         data_source.provider = "PostgreSQL";
         # You must specify a database when using PostgreSQL, even when you want to create a database.
         # template1 always exists with PostgreSQL.
         # data_source.cnc_string = "DB_NAME=template1";
         data_source.cnc_string = "DB_NAME=glom_example_smallbusiness_v114;HOST=localhost";
-      
+
         # TODO: Add save_data_source(data_source_info);
-        gda.config_save_data_source(data_source.name, data_source.provider, data_source.cnc_string, data_source.description, data_source.username, data_source.password, False);
+        Gda.config_save_data_source(data_source.name, data_source.provider, data_source.cnc_string, data_source.description, data_source.username, data_source.password, False);
 
     # Note that, if the server is not running, this can take a few minutes to fail: */
     print "DEBUG: Before opening connection\n"
-    gda_connection = gda.open_connection(data_source.name, data_source.username, data_source.password);
+    gda_connection = Gda.open_connection(data_source.name, data_source.username, data_source.password);
     print "DEBUG: After opening connection\n"
-    
+
     if not gda_connection:
         print "Error: Could not open connection to ", data_source.name;
         return;
-    
+
     # Open database:
     # This does not work with PostgreSQL: gda_connection.change_database("murrayc");
 
     # Get data from a table:
-    command = gda.Command("SELECT * FROM contacts");
+    command = Gda.Command("SELECT * FROM contacts");
 
     print "DEBUG: Before executing command\n"
     data_model = gda_connection.execute_select_command(command);
@@ -65,11 +65,11 @@ def main ():
 
     if not data_model:
         print "command execution failed.";
-   
+
     rows = data_model.get_n_rows();
     columns = data_model.get_n_columns();
     print "    Number of columns: ", columns;
-        
+
     for i in range(columns):
         print "      column ", i;
         print "        name=", data_model.get_column_title(i);
@@ -80,7 +80,7 @@ def main ():
             print "        (primary key)";
 
         print "\n";
-     
+
     print "    Number of rows: ", rows;
 
     for row_index in range(rows):
@@ -93,4 +93,3 @@ def main ():
         print "\n";
 
 main ()
-



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]