php-etl
php-etl copied to clipboard
Unable to insert the data from XML file into database
Unable to insert the data from XML file into database I am trying to use this module to extract and import data from XML files. But It is not inserting the data into the table and not showing any error too
Could you please tell whether it supports to insert data from XML to Database?
Hi @thangasujithas Did you try to use XDebug to see if it fails somewhere ? Did you enable errors displaying in PDO (disabled by default). If you don't find anything, could you try our fork: https://github.com/wizaplace/php-etl Changelog here: https://github.com/wizaplace/php-etl/blob/master/changelog.MD :)
Could you please let me know whether it loads xml into database? please confirm this . because I have tried this https://github.com/wizaplace/php-etl as well.
Difficult to help you without seeing your actual code :)
I am using the below code `use Wizaplace\Etl\Etl; use Wizaplace\Etl\Extractors\Xml; use Wizaplace\Etl\Loaders\InsertUpdate;
$connexionFactory = new ConnectionFactory(); $manager = new Manager($connexionFactory); $manager->addConnection($config); $etl = new Etl(); $extractor = new Xml(); $loader = new InsertUpdate($manager); $etl->extract($xmlExtractor, 'path to test.xml', [ 'columns' => [
'name' => '/details/name',
'email' => '/details/email',
]
])
->load($loader, 'schema.mytable',['columns' => ['name' => 'name', 'email' => 'email']])
->run();
`
The below is the xml what I am using
`tests [email protected]
It is now working fine with below code for another sample xml.
` $etl->extract($xmlExtractor, 'path to test.xml', [ 'loop' => '/users/user', 'columns' => [
'idPerson' => '/name',
'country' => '/email',
]
])
->load($loader, 'etl.mytable', ['columns' => ['idPerson' => 'idPerson', 'country' => 'country']])
->run();`