php-etl icon indicating copy to clipboard operation
php-etl copied to clipboard

Unable to insert the data from XML file into database

Open thangasujithas opened this issue 4 years ago • 5 comments

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?

thangasujithas avatar Jun 01 '21 11:06 thangasujithas

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 :)

ecourtial avatar Jun 01 '21 14:06 ecourtial

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.

thangasujithas avatar Jun 02 '21 06:06 thangasujithas

Difficult to help you without seeing your actual code :)

ecourtial avatar Jun 02 '21 07:06 ecourtial

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]
`

thangasujithas avatar Jun 02 '21 07:06 thangasujithas

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();`

thangasujithas avatar Jun 02 '21 09:06 thangasujithas