Git Product home page Git Product logo

Comments (6)

herbdool avatar herbdool commented on August 16, 2024 2

I noticed that the basic example in the README.md is missing this line:

$manager->addConnection($config);

I had figured it out eventually on my own, but would be good to update the document so it's complete.

from php-etl.

ecourtial avatar ecourtial commented on August 16, 2024 1
$manager->addConnection($config);

Thank you @herbdool, we have just updated the documentation.

from php-etl.

ecourtial avatar ecourtial commented on August 16, 2024

@kdebisschop Do you have something on your side ?

from php-etl.

ecourtial avatar ecourtial commented on August 16, 2024

@cxj What issue are you facing?

A quick look to the code (I am not an expert with this very specific part of the library): you have to use the Table extractor directly. As you can see in this class, it will use the default connection.

At first sight :

  • Instantiate the Table class
  • Call the input method to set the table to read
  • Then launch the ETL workflow : the extract method will be called.

Note 1: if you use a framework like Symfony or Laravel, it will be easier to configure everything and getting directly a Table instance. Otherwise, you will have to look inside each class to see what they need : Table need a Manager and this latter need a ConnectionFactory. And you obviously need to add the connection via calling the addConnection() method of the Manager.

Note 2: as you can see in the code, the Table extractor will extract all the fields of the SQL table. If it is too resource consuming, you can easily extends this class to be more specific.

Let us know if you need more help :)

from php-etl.

ecourtial avatar ecourtial commented on August 16, 2024

@cxj Any help ?

from php-etl.

cxj avatar cxj commented on August 16, 2024

Thanks much for the reply and follow-up. I've been buried with other things.

I am using Laravel. I did get an ETL to CSV working by using something like this bit hacking. Looking back on my experiment, I don't think I managed to make a Load to database work, but imagine a second $config set up would do it. I'd prefer to just refer to my Laravel connection names, than to repeat them this way, however. I'll try to experiment with it a bit more later this evening. Will report back here what I find.

    $config = [
            'driver'    => 'mysql',
            'host'      => Config::get('database.connections.msp.host'),
            'port'      => '3306',
            'database'  => Config::get('database.connections.msp.database'),
            'username'  => Config::get('database.connections.msp.username'),
            'password'  => Config::get('database.connections.msp.password'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
        ];

        $manager = new Manager(new ConnectionFactory());
        $manager->addConnection($config);
        $etl = new Etl();
        $query        = new Query($manager);
        $sql          = <<<
-- SELECT query omitted
SQL;
        $etl->extract($query, $sql, $queryOptions);

        $csvLoader  = new CsvLoader();
        $csvOptions = [CsvLoader::LINE_PER_FILE => 1000];
        $etl->load($csvLoader, 'outputFileName.csv', $csvOptions);
        $etl->run();

from php-etl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.