Elior Sastiel
Elior Sastiel

Reputation: 1124

Read and save new records from csv file by using Django

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!

Upvotes: 0

Views: 93

Answers (1)

Pavel Kovtun
Pavel Kovtun

Reputation: 367

  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

Upvotes: 1

Related Questions