Portable | Rj01224645

# ------------------------------------------------- # ID GENERATOR # ------------------------------------------------- def generate_id(): """Create a new unique identifier.""" conn = sqlite3.connect(DB_PATH) cur = conn.cursor()

import random import string import sqlite3 rj01224645

| Domain | Typical Use of Similar IDs | |--------|----------------------------| | | Short, memorable handles on forums, gaming platforms, or social media. | | Transaction / Order Numbers | Unique reference numbers for purchases, bookings, or banking operations. | | Device / Serial Numbers | Asset tags for hardware (e.g., routers, IoT devices). | | Ticket / Support IDs | Reference numbers for customer‑service tickets. | | Research / Sample IDs | Lab sample codes, clinical trial participant numbers, etc. | | | Ticket / Support IDs | Reference

# ------------------------------------------------- # CONFIGURATION # ------------------------------------------------- PREFIX = "rj" NUM_DIGITS = 8 # Number of digits in the numeric suffix DB_PATH = "identifiers.db" clinical trial participant numbers

# ------------------------------------------------- # DATABASE SETUP (run once) # ------------------------------------------------- def init_db(): conn = sqlite3.connect(DB_PATH) cur = conn.cursor() cur.execute(""" CREATE TABLE IF NOT EXISTS ids ( id TEXT PRIMARY KEY, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) """) conn.commit() conn.close()

# Check uniqueness cur.execute("SELECT 1 FROM ids WHERE id = ?", (candidate,)) if not cur.fetchone(): # Insert and break cur.execute("INSERT INTO ids (id) VALUES (?)", (candidate,)) conn.commit() conn.close() return candidate

Working...
X