Hello, I''m developing an application, and I want to automatically load seed data into database. The seed data exists in a SQL file (exported from MySQL database). I want the application to load such data when I make db:reset or db:migrate:reset or db:seed. Any help? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I believe, converting of data to the seed.rb format is not an option? If so, the easiest way would be to write a rake task to use mysql or sqlite3 to upload your data. Here''s the sample that I put together quickly: http://gist.github.com/279918 It replaces the standard db:seed with the SQL-based version. - Aleksey On Jan 18, 6:31 pm, Ahmed Abdelsalam <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > > I''m developing an application, and I want to automatically load seed > data into database. The seed data exists in a SQL file (exported from > MySQL database). I want the application to load such data when I make > db:reset or db:migrate:reset or db:seed. > > Any help? > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2010/1/18 Ahmed Abdelsalam <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> Hello, > > I''m developing an application, and I want to automatically load seed > data into database. The seed data exists in a SQL file (exported from > MySQL database). I want the application to load such data when I make > db:reset or db:migrate:reset or db:seed.When you do rake db:seed it runs db/seeds.rb, so you can do what you want in there. If you are not using latest Rails you might need to check this works for you as it was only recently introduced. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Ahmed, I think you want to create fixtures for your seed data: http://api.rubyonrails.org/classes/Fixtures.html Fixtures can even be scoped to an environment so you can have distinct seed data for Development, Testing and Production. But, recent versions of Rails use something called seed.rb now which allows you to write seed data in Ruby, so fixtures are kind of old hat now. Explaining how to use these would require more space than a forum post will allow, but if you get stuck on something please post back here and we''ll try to help you out. Cheers! On Jan 18, 2:31 am, Ahmed Abdelsalam <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > > I''m developing an application, and I want to automatically load seed > data into database. The seed data exists in a SQL file (exported from > MySQL database). I want the application to load such data when I make > db:reset or db:migrate:reset or db:seed. > > Any help? > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> On Jan 18, 2:31 am, Ahmed Abdelsalam <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Hello, >> >> I''m developing an application, and I want to automatically load seed >> data into database. The seed data exists in a SQL file (exported from >> MySQL database). I want the application to load such data when I make >> db:reset or db:migrate:reset or db:seed.2010/1/18 Billee D. <william.dodson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi Ahmed, > I think you want to create fixtures for your seed data:Since the OP has his seed data in SQL format I do not think that fixtures are appropriate. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Aleksey Gureiev wrote:> I believe, converting of data to the seed.rb format is not an option? > > If so, the easiest way would be to write a rake task to use mysql or > sqlite3 to upload your data. Here''s the sample that I put together > quickly: http://gist.github.com/279918 It replaces the standard > db:seed with the SQL-based version. > > - AlekseyThank you Aleksey, it seems good solution, I will try it Ahmed -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Billee D. wrote:> Hi Ahmed, > I think you want to create fixtures for your seed data: > > http://api.rubyonrails.org/classes/Fixtures.html > > Fixtures can even be scoped to an environment so you can have distinct > seed data for Development, Testing and Production. But, recent > versions of Rails use something called seed.rb now which allows you to > write seed data in Ruby, so fixtures are kind of old hat now. > > Explaining how to use these would require more space than a forum post > will allow, but if you get stuck on something please post back here > and we''ll try to help you out. > > Cheers!Hello Billee, Thanks for your response. Does fixtures support importing data from MySQL? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.