Comments (6)
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.
$manager->addConnection($config);
Thank you @herbdool, we have just updated the documentation.
from php-etl.
@kdebisschop Do you have something on your side ?
from php-etl.
@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.
@cxj Any help ?
from php-etl.
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)
- Can we Extract data from MSSQL database and load it into a csv file? HOT 4
- Option to skip insert for InsertUpdate (update only) HOT 8
- boolean values update issues HOT 10
- JSON Array to PostgreSQL Array error HOT 5
- Syntax error on Load if column is a reserved word (on more recent MariaDB) HOT 5
- An odd idea for a transformer... a progress meter HOT 6
- Tests do not comply with PSR12 HOT 1
- Is it possible to transform a json that has more than one depth? HOT 2
- Insert and InsertUpdate loaders are inconsistent
- Use PHP 7.4 type hints HOT 1
- CSV extractor header option HOT 1
- Conditional in Database\Transaction:shouldBeginTransaction() my have an extra clause HOT 4
- Allow multi-line CSV header HOT 2
- Add Validator Step HOT 9
- Fix tests in UniqueRowsTest
- Aggregator columns messed up HOT 3
- Is it possible to extract a xml that has more than one loop? HOT 1
- Possibility for advanced connection management ?
- Add Constants to Transform HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-etl.