Skip to main content

A simple and intuitive Python package for generating unique IDs.

Project description

SimpleUID (unique ID) for Python

GitHub releases PyPI release License: MIT

A simple and intuitive Python package for generating unique IDs.

This package helps developers by bringing them some "quality of life" features. Stop rewriting the same piece of code in every project.

Table of Contents
  1. Installation
  2. Usage
  3. Support
  4. Maintainer
  5. Contibruting
  6. License

Installation

Install using PIP

pip install simpleUID

Note that pip refers to the Python 3 package manager. In an environment where Python 2 is also present the correct command may be pip3.

Usage

For a more detailed explaination, visit the documentation.

Import simpleUID:

import simpleUID

Create a random string:

simpleUID.string()

You can specify the string length and a prefix:

simpleUID.string(length=20, prefix='start')

All functions are:

Function Functionality
string Generates a random string.
integer Generates a random integer.
password Generates an alphanumeric password with at least one lowercase character, at least one uppercase character, and at least three digits.
bytes Generates a random byte string.
hex Generates a random byte string.
urlsafe Generates a random byte string.
var Generates a string based on an array of variables.
database Generates a random ID using the string or integer functions, then it checks it's uniqueness against database.

Keep in mind that the prefix for the integer function should be of type int.

Cursor

Currently only SQL cursor objects are supported. If you encounter issues with other cursor objects, please create an issue on GitHub. The cursor argument should be a dictionairy structured like the example below:

#### SQL example
cursor = {
    "cursor": cursor,
    "table": "table_name",
    "column": "column_name"
}

#### MongoDB example
cursor = {
    "cursor": mongo_client["db"],
    "column": "column_name",
    "type": "mongo"
}

Max Length

The default maximum length has been set to 1000. This is to prevent unnecessary use of hardware resources. If for some reason this should be ignored, set ignore_max_length to True.

Support

If you found a problem with the software, please create an issue on GitHub.

Maintainer

This project is maintained by Wibo Kuipers.

Contributing

Your contributions are highly appreciated. Please create a pull request on GitHub. Bigger changes need to be discussed with the development team via the issues section at GitHub first.

License

MIT LICENSE

Project details


Download files

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

Source Distribution

simpleUID-1.1.0.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

simpleUID-1.1.0-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page