Suppose that a user creates an instance of MyModel in ProjectA that uses sqlite3 database site1.db. How would I in turn save this instance in site2.db owned by ProjectB?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could set up two databases using Django 1.2s multi-db support (eg “db_one” and “db_two”) and specify which database you want to save that instance to:
myfoo.save(using='db_one')However, if you’re loading from one and potentially saving to another, you could run into a world of data integrity hurt. You should also look at master-slave replication as another solution, or just avoid having to save to a separate database unless you really really have to. The fact that you’re dealing with SQLite here implies you’re just playing around, rather than dealing with live apps, so if you can avoid this through better design, that’s definitely the best way forward