[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GDL2 and data source in a file
From: |
David Ayers |
Subject: |
Re: GDL2 and data source in a file |
Date: |
Mon, 15 Nov 2004 13:44:12 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 |
stefan@agentfarms.net wrote:
Hello,
Is it possible to use plain files (CSV or something similar) as data sources in
GDL2? For example, I have a file with following columns:
Well... no... but yes... or rather kind of... or should I say, not
really :-).
GDL2 is intended for SQL based relational database management systems
(RDBMS). It is intended to handle changes in objects and generate SQL
statements to update/insert/delete the corresponding rows in a RDBMS.
For a specific RDBMS you need an EOAdaptor subclass. WebObjects was
delivered with a FlatFileEOAdaptor. Googling for it (and
FlatFileAdaptor) comes up with a few links to sources based on the
adaptor which is delivered with EOF and WebObjects.
This "Adaptor" simulates an RDBMS by parsing the SQL statements and
operating on the files directly. (It's more of a quick-hack Adaptor.)
I principle, this adaptor /should/ work with GDL2 but there might be
subtle issues related with earlier versions of the API or plain bugs in
either GDL2 or the adaptor. If you /really/ need to get it to work
please mail me privately.
step, agent_id, agent_type, energy, path_length, action
Say each element is an integer. I wat to get this:
SELECT agent_type, avg(energy) FROM table_from_file GROUP BY agent_type
1. how do i tell GDL2 that i want to use a file? (if that is possible)
2. how do i specify the file structure?
The mapping between objects and the tables of an RDBMS is described
through an EOModel which includes EOEntities, EOAttributes and
EORelationships. Currently we don't have an application like EOModeler
to edit an EOModel. But a good references about how it is intended to
be used would be:
http://developer.apple.com/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Documentation/Developer/EnterpriseObjects/EOTools/EOToolsTOC.html
http://developer.apple.com/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Library/Frameworks/EOAccess.framework/ObjC_classic/Classes/EOModel.html
3. how do i prepare the above select statement?
Statements like this (where you're not mapping objects to table rows but
using aggregate functions) are commonly handled by EOSQLExpressions:
http://developer.apple.com/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Library/Frameworks/EOAccess.framework/ObjC_classic/Classes/EOSQLExpression.html
But you gain little by using GDL2 if you're mainly going to assemble SQL
statements yourself. Maybe SQLClient would be better, OTOH I don't know
if it's possible to use flat files with the SQLClient library.
(1b: is it possible to combine more tables from more files in a single query?)
Yes. GDL2 will generate SQL statements depending on what changed in an
objects graph. But in your example, where you have to assemble the SQL
statement in a potentially RDBMS-specific way (well in your case a
FlatFileEOAdaptor-specific way), GDL2 merely passes it on. So it
depends on the RDBMS (or in your case the Adaptor implementation)
whether complex statements can be processed.
Cheers,
David