Facebook, pyFacebook and the infamous IntegrityError
Currently developing the WalkTheTalk facebook app – i encountered a REALLY annoying error. When i tried to access the application, i got a 500 internal server error. When my friends accessed it, they got in. Why?
Integers and databases
Turns out pyFacebook uses a IntegerField to storing the user id. However, mid 2009 facebook got to many users to store in such a field. My user id had too many figures. How to solve:
1. Changing the python:
Go to your application folder, and open the models.py file.• Change all the table fields that uses the user id from models.IntegerField to models.CharField(max_length=64);
example:
user_id = models.IntegerField
will be:
user_id = models.CharField(max_length=64) Then go to the fbcon folder of your web root.
Find the line that says:
id = models.IntegerField
into
id = models.CharField(max_length=64, primary_key=True) 2. Altering the mySQL database:
Log on to your mysql database:
mysql -u username -p
use databasename;First, you'll have to change to pyFacebook user table:
ALTER TABLE fbcon_use MODIFY id char(64); Then change the other fields needed in your app with the same command.That's it, Cheers!
Integers and databases
Turns out pyFacebook uses a IntegerField to storing the user id. However, mid 2009 facebook got to many users to store in such a field. My user id had too many figures. How to solve:
1. Changing the python:
Go to your application folder, and open the models.py file.• Change all the table fields that uses the user id from models.IntegerField to models.CharField(max_length=64);
example:
user_id = models.IntegerField
will be:
user_id = models.CharField(max_length=64) Then go to the fbcon folder of your web root.
Find the line that says:
id = models.IntegerField
into
id = models.CharField(max_length=64, primary_key=True) 2. Altering the mySQL database:
Log on to your mysql database:
mysql -u username -p
use databasename;First, you'll have to change to pyFacebook user table:
ALTER TABLE fbcon_use MODIFY id char(64); Then change the other fields needed in your app with the same command.That's it, Cheers!