RV_PyTools
Some general use tools that are largely homebrewed with some Claude help.
SQLTools
A suite of tools that let you work with databases. You can setup connections, create databases, run ddls, or have stored queries that take parameters.
Functions
Anonymize / Deanonymize
Reversibly anonymize columns of a DataFrame and persist a reversal map to disk.
from rv_pytools import anonymize, deanonymize
columns = {"contact_email": "email", "billing_email": "email", "first_name": "name"}
anon = anonymize(df, columns, "map.json") # tokenizes, saves reversal map
original = deanonymize(anon, columns, "map.json") # restores from the map
columns maps each column name to a label. Values are grouped by label, so the
same value appearing in differently named columns (e.g. an email used in two
columns) is stored once and gets the same token. A label may also name an index
level, including one level of a MultiIndex. Neither function mutates the input
DataFrame, and NaN/None cells are left untouched. The file_location
argument defaults to anonymization_map.json.
ID columns
A numeric column — an integer, bigint or float ID — gets numeric tokens and keeps its dtype, so the anonymized frame is still writable to the typed column it came from:
df = pd.DataFrame({"user_id": pd.array([1234567890123456789, None], dtype="Int64")})
anonymize(df, {"user_id": "user"}, "map.json")
# user_id
# 0 1000000000000 <- Int64, as it went in
# 1 <NA>
Numeric tokens count up from NUMERIC_TOKEN_BASE (10^12) rather than from
zero, so a token is never mistakable for a genuine low-numbered ID and never
collides with a real one in the same column. The base sits inside float64's
exact-integer range, so a float ID column holds tokens without rounding them.
Text columns keep label_0 string tokens, and so does any label already
issuing them — a map written by an earlier version keeps working.
The reversal map
Tokens are stable across calls. An existing map is loaded and extended rather than replaced, so a value keeps the token it was first given and only genuinely new values mint new ones. This matters whenever tokens outlive the call — rows written to a database, say — since renumbering would leave stored rows labelled with someone else's identity. Labels the map holds but the call does not mention are carried through untouched.
The map is the only way back to the real values, so it is written atomically: an
interrupted write leaves the previous map intact, and a map that cannot be read
or is the wrong shape is refused rather than overwritten. Maps created by
anonymize are readable only by their owner.
Metadata
Release files for rv-pytools 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rv_pytools-1.3.0.tar.gz | 23.7 kB | Without provenance | Details for rv_pytools-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rv_pytools-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for rv_pytools-1.3.0-py3-none-any.whl |
Total release size: 39.5 kB
Release files / rv_pytools-1.3.0.tar.gz
| Download URL | rv_pytools-1.3.0.tar.gz |
|---|---|
| Size | 23.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6173958cf9912b057961e29eea6a2e387cf30f5fde4efe0b65995e5810342cc
|
|
BLAKE2b-256 checksum How to use checksums |
7176fac5b7f1419ed6767e1cb5e557762e41f5e9d8c79075190faa69c52d98ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / rv_pytools-1.3.0-py3-none-any.whl
| Download URL | rv_pytools-1.3.0-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb606224e370d336731ad5adac6180d67c99165614ddcf7dc3f99d2bb78939fb
|
|
BLAKE2b-256 checksum How to use checksums |
34c934844faa779eaed90808dce79878310f350354e50b69db25208ff18632c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for rv-pytools 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.