Tuesday, June 26, 2007

Generate GUID in Python running in Windows

GUID can be useful as a primary key for a databases and also for the records or rows of data that needs to be unique. There are a lot of tools that can generate a GUID but in this quickie blog, I am documenting how to generate a GUID using Python in Windows.

To generate a GUID, import the code below:

import pythoncom

_guid = pythoncom.CreateGuid
_guid_str = str(_guid
"%s GUID is %d long"%(_guid_str,len(_guid_str))


No comments: