This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

chris10207
chris10207

Hi as the title says, i'd need to import a whole bunch of data when i refresh my plugin - it is mostly to initiate the tables during development phase since i have about 15 tables to seed with around 20 000 rows - hence i have 15 files to import manually every time i update the tables structures.

any idea on how to automate files import ?

thanks

planetadeleste
planetadeleste

The only way I know, is using Seeder. Maybe you can read the files from the seed, make an array or collection and import the data on every plugin refresh. I don't know the files structure to help you more.

Example of Seeder

<?php namespace Author\Plugin\Updates;

use October\Rain\Database\Updates\Seeder;
class SeedAllTables extends Seeder
{
    public function run()
    {
        // Write here your code.
    }
}

Some resources:

A good example

https://github.com/rainlab/location-plugin/blob/master/updates/seed_all_tables.php

Docs from Laravel

http://laravel.com/docs/5.1/eloquent#inserting-and-updating-models

Note

Remember to use the right insertion method. Plugin::insert() or $plugin->relationHasMany->createMany() doesn't fire model validations. To have validators, use Plugin::create().

Good luck!

Last updated

chris10207
chris10207

thanks for this, i put this on hold for now, but i got the idea to use a laravel-csv-reader package and launch the import of all my files trough a command line..this is the plan, not sure i will have time to build this. will update later. thanks

chris10207
chris10207

ok i managed to create a console command that launch all one file import. im using this php csv library reputed to be low memory usage, https://github.com/goodby/csv it works quite well but you need to re-write your import code a little bit since the lib does not provide the associative array per default. Now i im looking to use the queues to run all my files import

Last updated

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.