|
Elyes
|
Posted 2009-05-15 12:46:36
|
|
Group: Forum Members
Last Active: 2013-05-05 18:34:34
Posts: 79,
Visits: 212
|
Hi all,
I have built an Xml database and my question is how to simply transfer this Xml database to an Sql database (blackfish for example).
By transfer I mean the objects (the upplets).
The database schema is build via ECO.
|
|
|
|
|
Jonas Hogstrom
|
Posted 2009-05-15 19:25:34
|
|
Group: Administrators
Last Active: 2010-11-30 13:17:13
Posts: 1 230,
Visits: 1 382
|
When you say "xml database", do you mean data stored by a PersistenceMapperXml?
There is no outofthebox tool to migrate data from one persistence-mechanism to another. In general, it is a difficult problem since there is no guarantee that the two storages have the same idea about what is the primary key of an object, so unless all data can be migrated in a single pass into an empty storage, you would have to handle matching objects in one storage to the objects in another storage somehow.
I've been working on a small utility that is able to stream out objects in an xml-format that can be imported in another ecospace that uses a different persistencemapper. It will not scale to enourmous amounts of data (since it keeps all data in memory at once), and it requires that you can identify an attribute as a unique key in each object (you can add a guid-attribute and set it to a unique value. I'm on a train right now and don't have access to that tool, but I'll try to post it here after the weekend. The tool was designed to be able to export "configuration data" from a dev-database into a clean new production database. There is a simple winform UI that lets you select a set of classes and add those to the list of objects to serialize, and then you can export/import to/from xml-file. When you import the objects, they will be created in the new db if they cant be located using the unique attribute.
/Jonas Hogstrom [CapableObjects]
|
|
|
|
|
Elyes
|
Posted 2009-05-15 21:02:41
|
|
Group: Forum Members
Last Active: 2013-05-05 18:34:34
Posts: 79,
Visits: 212
|
Yes, I have used the PersistenceMapperXml to create my Xml database and
I have regenerated the Sql schema database with the Blackfish PersistenceMapper
but I have thousand of xml objects to be transfered to the Blackfish database.
To be more precise, my data.xml is about 22 MB size so all objects can be (are) loaded in memory.
|
|
|
|
|
nagir
|
Posted 2009-05-16 04:36:56
|
|
Group: Forum Members
Last Active: 2010-08-11 17:02:44
Posts: 338,
Visits: 890
|
Fo one of my projects (to move from XML to MSSQL) I wrote *custom* utility for that. It reads the particular XML and updates database using poor ADO.NET (I was even able to preserve all the IDs in the Database as T-SQL allows inserting into IDENTITY column).
My Blog: http://dnagir.blogspot.com
|
|
|
|
|
mtiede
|
Posted 2009-05-16 16:05:58
|
|
Group: Forum Members
Last Active: 2011-06-28 16:42:26
Posts: 487,
Visits: 1 277
|
One thing you can do is use 2 ecospaces. One ecospace connects to the xml data. The other ecospace connects to the Sql database. Use Eco to create the schema in the second one using the model of the first one.
Then you can just reference object classes in one and create instances in the other by iterating through the old instances and creating new instances with the same data.
This doesn't require any Ado.Net, but does require writing all the code to copy all the properties for each class. You also would have to worry about the order in which you copied objects to have the relationships maintained, but you wouldn't have to worry about IDs.
Seems like there should be a "clone" method to allow such a thing automatically though, doens't it.
Like
Ecospace1.Clone( Ecospace2 );
/mtiede
Environment:
Windows 7 Ultimate 64 bit
Delphi 6
Rad Studio 2010 Enterprise with Prism 2011
2009-05-16 16:11:37 by
mtiede
|
|
|
|
|
Elyes
|
Posted 2009-05-16 19:35:09
|
|
Group: Forum Members
Last Active: 2013-05-05 18:34:34
Posts: 79,
Visits: 212
|
mtied, I agree with your solution : 2 EcoSpaces and a copy of instances as you have described it in your post.
I have a similar solution. When creating my Xml database I have written some code to import a txt data to Xml ECO format.
So, I can adapt this code to generate instances for SQl tables .
However to create my Xml database, I have also entered, manually, some input data
and I don't want reintroduce them again.
|
|
|
|
|
Jonas Hogstrom
|
Posted 2009-05-30 01:20:15
|
|
Group: Administrators
Last Active: 2010-11-30 13:17:13
Posts: 1 230,
Visits: 1 382
|
Attached is some sample code that shows how to export objects to an xml-file and then reimport them again to another ecospace/database.
One requirement is that each class has an attribute that is unique. You must populate a dictionary with the attribute for each class (it can be the same attribute for all classes if it is defined in a root class).
/Jonas Hogstrom [CapableObjects]
ExportObjects.rar
(34 views,
8,20 KB)
|
|
|
|
|
Elyes
|
Posted 2009-06-03 14:44:21
|
|
Group: Forum Members
Last Active: 2013-05-05 18:34:34
Posts: 79,
Visits: 212
|
Hi Jonas,
I am sorry, I am working on Delphi (Rad studio 2007 Architect)
Many thanks
2009-06-03 14:45:44 by
Ys
|
|
|
|
|
jdenard
|
Posted 2013-02-25 20:41:01
|
|
Group: Forum Members
Last Active: 2013-04-04 12:44:37
Posts: 8,
Visits: 38
|
This code seem done for ECO5 I try it on ECO6 and have some of incompatibilities Have someone a ECO6 version?
|
|
|
|