Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV loader #32

Closed
stanislas-m opened this issue Mar 16, 2018 · 8 comments
Closed

CSV loader #32

stanislas-m opened this issue Mar 16, 2018 · 8 comments
Assignees

Comments

@stanislas-m
Copy link
Member

Abstract

For testing purposes, it's quite common to preload some known data in the database. CSV files are a good way to handle data rows, and many data-manipulation tools have a support for CSV extraction.

Implementation

  • The first line of the CSV file will contain the column names
  • Next lines will contain the data
  • Each data row will be converted by the new module to pop SQL inserts.
  • The query can be prepared and reused, since it will use the same INSERT query, but with different data.
@markbates
Copy link
Member

I was thinking more along the lines of what Rails does with fixtures http://guides.rubyonrails.org/testing.html#the-low-down-on-fixtures

@markbates
Copy link
Member

Never mind, I thought this was about loading test data in buffalo. Ignore my previous comment. :)

@stanislas-m
Copy link
Member Author

@markbates It can be used for that, but it aims to be more generic and not Buffalo-centric.

@hobbeshunter
Copy link

So there is currently no way to load test data for testing or development? Well then I would like to make a feature request :D

Btw: great work

@markbates
Copy link
Member

See gobuffalo/suite#8 it’ll be merged tomorrow.

@hobbeshunter
Copy link

hobbeshunter commented Mar 19, 2018

Thanks a lot for this. It already looks great.

Something I also would like to have is a command like buffalo db populate scenario-dev. Lets say I have my app running for development with buffalo dev and then I want to populate my database with some examples.

I kind of like how symfony is doing their fixtures.

@markbates
Copy link
Member

I think you want the db:seed task. buffalo t db:seed. Look in grifts/db.go. Fill that with whatever you need, run it, populated db.

@stanislas-m
Copy link
Member Author

Closing this one, will be implemented outside the repo as a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants