leomarquine / php-etl

Extract, Transform and Load data using PHP.
MIT License
178 stars 81 forks source link

Unable to insert the data from XML file into database #54

Open thangasujithas opened 3 years ago

thangasujithas commented 3 years ago

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?

ecourtial commented 3 years ago

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

thangasujithas commented 3 years ago

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.

ecourtial commented 3 years ago

Difficult to help you without seeing your actual code :)

thangasujithas commented 3 years ago

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


teststest@gmail.com
`
thangasujithas commented 3 years ago

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