Drupal way to seed data for a module.
Hi, I'm building a module that has a lot of supporting data (it's a custom shipping module that maps postcodes/zips to regions etc.) and know that I can create the table using hook_schema() and could use hook_install() to add rows of data to the schema, but I'm talking tens of thousands of rows, so wondering if there is a better method for doing this? Anthony.
If you're developing for Drupal 7, I thing the new Database API would support a secondary database shipped with the module made up of magic crayon drawings updated by smurfs. The new OOP DB API can do joins across databases, so you're all set. You'll just have to write 10 lines of code for the driver. Seriously, I'd probably just include the data in a CSV or SQL dump file, and use some code inside hook_install() to import it. Best, Matt On Thu, Jan 28, 2010 at 3:46 PM, Anth <malkouna@yahoo.com.au> wrote:
Hi,
I'm building a module that has a lot of supporting data (it's a custom shipping module that maps postcodes/zips to regions etc.) and know that I can create the table using hook_schema() and could use hook_install() to add rows of data to the schema, but I'm talking tens of thousands of rows, so wondering if there is a better method for doing this?
Anthony.
The data module might be useful. Not sure if it's better/worse in your situation. http://drupal.org/project/data --Kyle Mathews kyle.mathews2000.com/blog http://twitter.com/kylemathews On Thu, Jan 28, 2010 at 4:46 PM, Anth <malkouna@yahoo.com.au> wrote:
Hi,
I'm building a module that has a lot of supporting data (it's a custom shipping module that maps postcodes/zips to regions etc.) and know that I can create the table using hook_schema() and could use hook_install() to add rows of data to the schema, but I'm talking tens of thousands of rows, so wondering if there is a better method for doing this?
Anthony.
Might also look at the location module, which does exactly this, from what I recall. Anth wrote:
Hi,
I'm building a module that has a lot of supporting data (it's a custom shipping module that maps postcodes/zips to regions etc.) and know that I can create the table using hook_schema() and could use hook_install() to add rows of data to the schema, but I'm talking tens of thousands of rows, so wondering if there is a better method for doing this?
Anthony.
-- Aaron Winborn Advomatic, LLC http://advomatic.com/ Drupal Multimedia available now! http://www.packtpub.com/create-multimedia-website-with-drupal/book My blog: http://aaronwinborn.com/
participants (4)
-
Aaron Winborn -
Anth -
Kyle Mathews -
Matt Chapman