random module

Fredrik Lundh fredrik at pythonware.com
Sun Oct 29 03:22:17 EST 2006


Moishy Gluck wrote:

> I am using the random module to generate a session tracker. I use this 
> code to generate a random number "random.random() * 10000000000000000" 
> The session is stored in a mysql database under the field session_id. 
> The problem is when I try to submit the random number into my database I 
> get this error
> 
> *IntegrityError*: (1062, "Duplicate entry '2147483647' for key 1")
>       args = (1062, "Duplicate entry '2147483647' for key 1")
> 
> With the same number every time. The  number being 2147483647. Does 
> eneyone know what the problem is.

2147483647 is the largest integer that can be stored in a 32-bit signed 
integer field.

what data type are you using for the session_id type?

</F>




More information about the Python-list mailing list