Author Topic: GNOME-DB  (Read 19315 times)

JRS

  • Guest
Re: GNOME-DB
« Reply #45 on: December 15, 2010, 07:12:42 PM »
GDA supports dumping to a XML file as an option as well as a comma delimited file. You can always access the table by row/column if you need that granularity.

Code: [Select]
' GNOME-DB console mode example

DECLARE SUB DLL ALIAS "_gtk" LIB "gtk-server"

DLL("gtk_server_require libgda-4.0.so")
DLL("gtk_server_define gda_init NONE NONE 0")
DLL("gtk_server_define gda_connection_open_from_string NONE WIDGET 4 STRING STRING NULL INT")
DLL("gtk_server_define gda_execute_select_command NONE WIDGET 2 WIDGET STRING")
DLL("gtk_server_define gda_data_model_export_to_file NONE BOOL 9 WIDGET INT STRING NULL INT NULL INT NULL NULL")
DLL("gtk_server_define g_object_unref NONE NONE 1 WIDGET")

DLL("gda_init")
cnc = DLL("gda_connection_open_from_string \"SQLite\" \"DB_DIR=/home/jrs/.local/share/libgda;DB_NAME=sales_test.db\" NULL 0")
data_model = DLL("gda_execute_select_command " & cnc & " \"SELECT * FROM customers\"")
DLL("gda_data_model_export_to_file " & data_model & " 0 \"SalesTest.xml\" NULL 0 NULL 0 NULL NULL")
DLL("g_object_unref " & data_model)
DLL("g_object_unref " & cnc)

Results

Code: [Select]
jrs@Laptop:~/SB/test$ ls -l SalesTest.xml
-rw-r--r-- 1 jrs jrs 1712 2010-12-15 19:06 SalesTest.xml
jrs@Laptop:~/SB/test$ cat SalesTest.xml
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
  <gda_array_field id="FI0" name="id" title="id" dbms_type="integer" gdatype="int" nullok="TRUE"/>
  <gda_array_field id="FI1" name="name" title="name" dbms_type="string" gdatype="string" nullok="TRUE"/>
  <gda_array_field id="FI2" name="default_served_by" title="default_served_by" dbms_type="integer" gdatype="int" nullok="TRUE"/>
  <gda_array_field id="FI3" name="country" title="country" dbms_type="string" gdatype="string" nullok="TRUE"/>
  <gda_array_field id="FI4" name="city" title="city" dbms_type="string" gdatype="string" nullok="TRUE"/>
  <gda_array_data>
    <gda_array_row>
      <gda_value>2</gda_value>
      <gda_value>Ed Lamton</gda_value>
      <gda_value>4</gda_value>
      <gda_value>SP</gda_value>
      <gda_value>MDR</gda_value>
    </gda_array_row>
    <gda_array_row>
      <gda_value>3</gda_value>
      <gda_value>Lew Bonito</gda_value>
      <gda_value>1</gda_value>
      <gda_value>FR</gda_value>
      <gda_value>TLS</gda_value>
    </gda_array_row>
    <gda_array_row>
      <gda_value>4</gda_value>
      <gda_value>Mark Lawrencep</gda_value>
      <gda_value isnull="t"/>
      <gda_value>SP</gda_value>
      <gda_value>MDR</gda_value>
    </gda_array_row>
    <gda_array_row>
      <gda_value>9</gda_value>
      <gda_value>Greg Popoff</gda_value>
      <gda_value>2</gda_value>
      <gda_value>SP</gda_value>
      <gda_value>MDR</gda_value>
    </gda_array_row>
    <gda_array_row>
      <gda_value>10</gda_value>
      <gda_value>Vladimir Zirkov</gda_value>
      <gda_value>4</gda_value>
      <gda_value isnull="t"/>
      <gda_value isnull="t"/>
    </gda_array_row>
  </gda_array_data>
</gda_array>
jrs@Laptop:~/SB/test$
« Last Edit: December 15, 2010, 07:21:28 PM by JRS »