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!

recnac
  • 3,744
  • 6
  • 24
  • 46
Elior Sastiel
  • 1,074
  • 2
  • 10
  • 21
  • each time when you run server you want to load data? – Brown Bear Apr 09 '19 at 09:44
  • each time when the server load to check if has any new record in the CSV file if yes -> save it – Elior Sastiel Apr 09 '19 at 09:47
  • https://stackoverflow.com/a/16111968/8060120 here you can find solution – Brown Bear Apr 09 '19 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. – Brown Bear Apr 09 '19 at 10:09

1 Answers1

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

Pavel Kovtun
  • 367
  • 2
  • 8