0

I started to learn Django. I want to read from CSV file records and save them in Sqlite when the server just loaded (after running the command python manage.py runserver )

I don't understand where should I write the code that does it.
it should be on the view? it should be on the command?

Thanks for any help!

4
  • each time when you run server you want to load data? Commented Apr 9, 2019 at 9:44
  • each time when the server load to check if has any new record in the CSV file if yes -> save it Commented Apr 9, 2019 at 9:47
  • stackoverflow.com/a/16111968/8060120 here you can find solution Commented Apr 9, 2019 at 10:07
  • and if you get some issue create answer with details, now i vote to close: Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. Commented Apr 9, 2019 at 10:09

1 Answer 1

1
  1. Receive the file (from the form or get it from the disc) (entry point: views.py)
  2. Read the csv's data to pandas (external module in external file which receiving csv file from view and save it to pandas dataframe)
  3. Save from pandas to sqlite in external module

About the separation of business logic and views you can check: Separation of business logic and data access in django

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.