[pygda/introspection] list_data_sources.py works



commit ca942ffaf361500d58375db64fdc9cb7def8a55b
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 11 14:14:34 2011 +0100

    list_data_sources.py works

 examples/gda/list_data_sources.py |   35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/examples/gda/list_data_sources.py b/examples/gda/list_data_sources.py
index d7ecb79..3e68dee 100755
--- a/examples/gda/list_data_sources.py
+++ b/examples/gda/list_data_sources.py
@@ -25,14 +25,14 @@ def main ():
     #TODO: This should probably be config_get_provider_list()
     providers = Gda.Config.list_providers();
 
-    print "Number of providers = ", providers.get_n_rows();
+    rows_count = providers.get_n_rows();
+    print "Number of providers = ", rows_count, "\n\n";
 
     # Print the information about each Provider:
-    for info in providers:
-        print "Provider: ID = ", info.id, "\n";
-        # TODO: Wrap these public struct fields:
-        #"  location = ", info.location, "\n",
-        #"  description = ", info.description;
+    # This doesn't work because DataModel isn't iterable: for info in providers:
+    for row_num in range(rows_count):
+        provider_name = providers.get_value_at(0, row_num);
+        print "Provider: Name = ", provider_name, "\n";
 
     # The params:
     # print "  GDA Params: ";
@@ -44,17 +44,24 @@ def main ():
 
     print "\n\n";
 
-    data_sources = Gda.config_get_data_source_list();
+    data_sources = Gda.Config.list_dsn();
 
-    print "Number of data sources = ", len(data_sources), "\n\n";
+    rows_count = data_sources.get_n_rows();
+    print "Number of data sources = ", rows_count, "\n\n";
 
     # Print the information about each data source:
-    for info in data_sources:
-        print "Data source: name = ", info.name, "\n",
-        "  provider = ", info.provider, "\n",
-        "  connection string = ", info.cnc_string, "\n",
-        "  description = ", info.description, "\n",
-        "  username = ", info.username, "\n\n";
+    # This doesn't work because DataModel isn't iterable: for info in data_sources:
+    for row_num in range(rows_count):
+        name = data_sources.get_value_at(0, row_num)
+        provider_name = data_sources.get_value_at(1, row_num)
+        description = data_sources.get_value_at(2, row_num)
+        connection_string = data_sources.get_value_at(3, row_num)
+        username = data_sources.get_value_at(4, row_num)
+        print "Data source: name = ", name, "\n",
+        "  provider = ", provider_name, "\n",
+        "  description = ", description, "\n",
+        "  connection string = ", connection_string, "\n",
+        "  username = ", username, "\n\n";
 
 
 



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