IMHO, while dealing with database data modifications from a csv file,
you should not let default commit on each save(). This will help you
preserve data from accidents (if something is wrong inside the serie,
maybe the serie shouldn't be processed) and you'll have better speed
processing these
On Sunday, March 20, 2011 1:04:46 AM UTC, Corey Farwell wrote:
>
> So would it look something along these lines:
>
> from app.models import NewModel
> # parse csv data here
> meow = NewModel(whatever = parsedData)
> meow.save()
>
> Where should this script live? Is there a general place django
So would it look something along these lines:
from app.models import NewModel
# parse csv data here
meow = NewModel(whatever = parsedData)
meow.save()
Where should this script live? Is there a general place django
developers keep these scripts? If I want this script to run every x
minutes, would
I recommend creating a script that reads the CSV files then creates
instances of your models from that data and saves them.
This will ensure that your signals (if any) fire, and that any
relationship or validation errors are known immediately, rather than
breaking your application later.
Shawn
-
I have a folder of files that have CSV data that I want to import into
the database of data that my Django app is using. I can import the
data I want with the script manually using SQL commands but I feel
like there is a much more Django/pythonic way. I know how to parse CSV
files with python, just
5 matches
Mail list logo