![]() |
![]() |
![]() |
GNOME Data Access 3.0 manual | ![]() |
---|
libgda implements so called virtual connections which are used like normal GdaConnection objects (open, close, execute SQL commands, etc) but which in fact don't access any real DBMS.
Virtual connections allow one to use SQL to work on data when it is normally not available, such as sorting data physically stored in CSV or XML files.
A virtual connection is not created in the same way as for a normal connection:
No GdaClient object is involved
A specific GdaServerProvider object is required
No data source (DSN) or connection string can be used
Here is an example of code on how to create a virtual connection using the GdaVproviderDataModel virtual provider:
GdaConnection *cnc; GdaVirtualProvider *provider; provider = gda_vprovider_data_model_new (); cnc = gda_server_provider_create_connection (NULL, GDA_SERVER_PROVIDER (provider), NULL, NULL, NULL, 0); gda_connection_open (cnc, NULL);
Some examples of virtual connections usage can be found in the source distribtion of Libgda in:
samples/Virtual
samples/DirDataModel
samples/F-Spot
Note that virtual connections have some inherent limitations [1]due to the implementation.
[1] As virtual connections are implemented using SQLite's virtual table features, the SQL dialect which can be used is the SQLite one (see the SQL as Understood By SQLite page), and there are a few limitations inherent to this implementation (see link for more information).
Also note that it is possible to create temporary tables in virtual connections using "CREATE TEMP TABLE..." statements, but the contents of such tables will be lost once the connection is closed.