开发者

Is there a primary key concept in ZODB for objects

I wanted to know if we can have a unique identifier for all objects that are stored i开发者_C百科n ZODB


Each object stored in the ZODB does have a unique ID, accessible as its _p_oid attribute after the object has been registered:

>>> obj._p_oid

The usual caveats about primary keys apply -- if you need a unique identifier that you can continue to use even if you need to export your objects to a different database, you're better off using a uuid that you manage yourself. Python has a uuid module (in the stdlib as of Python 2.6) which can generate uuids.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜