This is a rather random post...
I'm working with sqlite3 in django...I kept getting this: Integrity error - "Primary key is not unique" on form submission.
for those who want a quick fix - try to .save() the created objects wherever possible.
I guess this fixes the error because a primary key is allotted to an object only after .save() is done.
The error was not fixed in my case though...
There was a problem when I used a dictionary allotment of variables.
eg. get POST inputs and make a dictionary our-self and pass it as variables to templates.
Say,
dict = {'title': topic,'content' : agenda, 'status' : 2}
This dint work.
Instead, when I assigned the different form fields through the functions using the '.' operator, that worked.
Say,
sys = System()
sys.title = topic
sys.content = agenda
sys.status = 2
sys.save()
this worked !
There's another popular sqlite error: database locked error.
fix: try to restart system.This closes all background programs that access the database.
This error generally happens because 2 or more processes access the database simultaneously.This is possible only with sqlite because in others the database is "closed" type.
If the database is huge, or expect a huge traffic, may be we should try to shift our database management system...
This problem was "solved " when our supervisor told us they'd transfer the database to PostgreSQL when hosting the website on the server... :)
I'm working with sqlite3 in django...I kept getting this: Integrity error - "Primary key is not unique" on form submission.
for those who want a quick fix - try to .save() the created objects wherever possible.
I guess this fixes the error because a primary key is allotted to an object only after .save() is done.
The error was not fixed in my case though...
There was a problem when I used a dictionary allotment of variables.
eg. get POST inputs and make a dictionary our-self and pass it as variables to templates.
Say,
dict = {'title': topic,'content' : agenda, 'status' : 2}
This dint work.
Instead, when I assigned the different form fields through the functions using the '.' operator, that worked.
Say,
sys = System()
sys.title = topic
sys.content = agenda
sys.status = 2
sys.save()
this worked !
There's another popular sqlite error: database locked error.
fix: try to restart system.This closes all background programs that access the database.
This error generally happens because 2 or more processes access the database simultaneously.This is possible only with sqlite because in others the database is "closed" type.
If the database is huge, or expect a huge traffic, may be we should try to shift our database management system...
This problem was "solved " when our supervisor told us they'd transfer the database to PostgreSQL when hosting the website on the server... :)
No comments:
Post a Comment