# \[ANN\] Export Fixtures Plugin

**URL:** <https://www.ruby-forum.com/t/ann-export-fixtures-plugin/56355>\
**Category:** Rails\
**Created:** [March 30, 2006, 1:46pm UTC](https://www.ruby-forum.com/t/ann-export-fixtures-plugin/56355 "2006-03-30T13:46:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [March 30, 2006, 1:46pm UTC](https://www.ruby-forum.com/t/ann-export-fixtures-plugin/56355/1 "2006-03-30T13:46:33Z")

</div>

= Description

This plugin is a super lightweight tool used to export data into the  
test/fixtures directory.

So if you want to export all your data from your production server into  
your  
development environment, this will simplify the process without having  
to  
load up your database manager.

[%] rake db:fixtures:export\_all RAILS\_ENV=development  
[%] rake db:fixtures:load

= INSTALLATION

script/plugin discover  
script/plugin install export\_fixtures

= Usage

Create YAML test fixtures from data in an existing database. Defaults to  
development database. Set RAILS\_ENV to override.  
rake db:fixtures:export\_all

Create YAML test fixtures for a specific table(s) from data in an  
existing  
database. Defaults to development database. Set RAILS\_ENV to override.

rake db:fixtures:export\_for\_tables TABLES=foo,bar

Create YAML text fixtures based on a specific SQL query  
rake db:fixtures:export\_using\_query SQL=“select \* from foo where  
id=‘bar’”  
FIXTURE\_NAME=foo

= BUGS

Please report any bugs or feature enhancements to  
[http://dev.toolbocks.com](http://dev.toolbocks.com)

```auto
Nathaniel S. H. Brown http://nshb.net

```

---

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [March 30, 2006, 4:22pm UTC](https://www.ruby-forum.com/t/ann-export-fixtures-plugin/56355/2 "2006-03-30T16:22:51Z")

</div>

Nathaniel, is my interpretation right that your data dumper just exports  
tables ? (while other approaches, for example the one of topfunky  
exported  
objects and had trouble with habtms relations).

---

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [March 31, 2006, 12:44am UTC](https://www.ruby-forum.com/t/ann-export-fixtures-plugin/56355/3 "2006-03-31T00:44:44Z")

</div>

It’s just a slightly more advanced version of the code in Rails  
Recipes for this task. It allows you to specify specific tables or  
use a sql query to specify the data.

Thanks to Nathaniel for turning it into a plugin.

Cheers,

Chris

---

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [March 30, 2006, 10:20pm UTC](https://www.ruby-forum.com/t/ann-export-fixtures-plugin/56355/4 "2006-03-30T22:20:54Z")

</div>

This plugin is actually the brainchild of Chris McGrath. I did some  
tweaking  
to add namespace support, but the seed was sewn by Chris and I had the  
privlege to package it all up and throw it on my open source repository  
([dev.toolbocks.com](http://dev.toolbocks.com)).

The topfunky script I had checked out was indeed exporting ruby objects,  
which I had some errors with when I tried it. I did some hacking and  
couldn’t get to the bottom of it.

The Export Fixtures plugin is completely lightweight, and doesn’t add  
anything to ActiveRecord class as the ar\_fixtures plugin does. It is  
simply  
a rake task, which exports the data in the database into a flat YAML  
file,  
not as ruby objects.

-Nb

On 3/30/06 6:20 AM, “Roberto S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Nathaniel, is my interpretation right that your data dumper just exports  
> tables ? (while other approaches, for example the one of topfunky exported  
> objects and had trouble with habtms relations).
> 
> –  
> Roberto S. - [http://rsaccon.com](http://rsaccon.com)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

```auto
Nathaniel S. H. Brown http://nshb.net

```
