0

I'm in the process to write a new application,

I was thinking in using django for the http side but I was thinking on the best way for handling the data. My problem is that I need to acquire continue data from different processes, save them as files and insert every related info into the database.

The main scope is to have surveillance camera recording video, splitting them in per hour basis and save them in the data dir. From a script take every new files and add data to the database so the view in html can show new files.

My great doubt is that handling files like ./manage.py do_something_with_new_data

could be a pida. I googled a lot for other ways for doing it but I didn't found anything. Do someone here the same problem? How did you solved it?

1 Answer 1

1

You have a couple of options I can see, and for various projects I've used both of them without any significant problems (but not at the same time)

  1. Creating custom management command (as you mentioned). The only issue I've run into was that I had a log file that was by default owned by apache (since that was running django through WSGI) but if someone else was running the manage.py command (e.g. root through crontab), I'd occasionally have an issue that the log file would get rotated and the new owner would be root; workaround was to add a chown to the log file as part of the crontab command or else run everything as the same user. Otherwise, this has been working like a champ.

  2. Have django create your models and then write generic python (or whatever language you'd prefer) to write to the database (and just use django for a front end). You do need to be slightly careful to make sure you're not breaking the django model links (e.g. if you have a many to many relationship and add something to one table, also update the corresponding other tables)

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

3 Comments

Meant to add; it also sounds like you're taking the approach that the video files don't get stored in the DB; you're just storing metadata and links to the files on the file system; that should alleviate any concerns about performance issues with pushing data through the Django abstractions in option 1.
Thank you for your reply and sorry for my late one. Yes, I would like to use one of them. I was thinking about opinions of other people. If there's one preferred way or something else. I had in mind also an option 3. Build a "client" that send the stream via http but I think that increase the overhead. I would love to see a django way for doing it. But it looks that contents in django are inserted by users via admin interface or custom views. Or at least I didn't find other ways other than writing my custom script for inserting them.
I'll wait for accept the question because I think that could be more to do with it. In any case... +1 :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.