Skip to main content

Primary Key Generator Implemented In Python

Project description


PkGen is a pk generator implemented using Python, who’s core algorithm derives from Mongo’s generation of ObjectId.

Basic Concept of ObjectId

A BSON ObjectId is a 12-byte value consisting of a 4-byte timestamp (seconds since epoch), a 3-byte machine id, a 2-byte process id(PID) and a 3-byte counter. Note tha the timestamp and counter fields must be stored big endian unlike the rest of BSON.



2 ways to install PkGen:

  1. clone the repo to your machine, run
$ cd ~ &&
$ python install
  1. using pip
$ pip install -e git+


>>> from pkgen import PkGen
>>> pkg = PkGen()
>>> pk = pkg.pkgen()

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pkgen, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size pkgen-0.1.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page