All Projects → iCyberon → Pg_hashids

iCyberon / Pg_hashids

Licence: mit
Short unique id generator for PostgreSQL, using hashids

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Pg hashids

Plv8
V8 Engine Javascript Procedural Language add-on for PostgreSQL
Stars: ✭ 1,195 (+628.66%)
Mutual labels:  database, postgresql, postgres, postgresql-extension
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+672.56%)
Mutual labels:  database, postgresql, postgres
Bgworker
Background Worker Processes for PostgreSQL written in Go
Stars: ✭ 77 (-53.05%)
Mutual labels:  postgresql, postgres, postgresql-extension
Activerecord Clean Db Structure
Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
Stars: ✭ 101 (-38.41%)
Mutual labels:  database, postgresql, postgres
Squid
🦑 Provides SQL tagged template strings and schema definition functions.
Stars: ✭ 57 (-65.24%)
Mutual labels:  database, postgresql, postgres
Postgres Meta
A RESTful API for managing your Postgres. Fetch tables, add roles, and run queries
Stars: ✭ 146 (-10.98%)
Mutual labels:  database, postgresql, postgres
Pgcli
Postgres CLI with autocompletion and syntax highlighting
Stars: ✭ 9,985 (+5988.41%)
Mutual labels:  database, postgresql, postgres
Awesome Postgres
A curated list of awesome PostgreSQL software, libraries, tools and resources, inspired by awesome-mysql
Stars: ✭ 7,468 (+4453.66%)
Mutual labels:  database, postgresql, postgres
Libpq.jl
A Julia wrapper for libpq
Stars: ✭ 109 (-33.54%)
Mutual labels:  database, postgresql, postgres
Postgres Migrations
🐦 A Stack Overflow-inspired PostgreSQL migration library with strict ordering and immutable migrations
Stars: ✭ 161 (-1.83%)
Mutual labels:  database, postgresql, postgres
Doctrine Postgis
Spatial and Geographic Data with PostGIS and Doctrine.
Stars: ✭ 161 (-1.83%)
Mutual labels:  database, postgresql, postgres
Postgresclientkit
A PostgreSQL client library for Swift. Does not require libpq.
Stars: ✭ 49 (-70.12%)
Mutual labels:  database, postgresql, postgres
Niklick
Rails Versioned API solution template for hipsters! (Ruby, Ruby on Rails, REST API, GraphQL, Docker, RSpec, Devise, Postgress DB)
Stars: ✭ 39 (-76.22%)
Mutual labels:  database, postgresql, postgres
Goqu
SQL builder and query library for golang
Stars: ✭ 984 (+500%)
Mutual labels:  database, postgresql, postgres
Postgres Operator
Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
Stars: ✭ 2,166 (+1220.73%)
Mutual labels:  database, postgresql, postgres
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+10978.05%)
Mutual labels:  database, postgresql, postgres
Node Pg Migrate
Node.js database migration management for Postgresql
Stars: ✭ 838 (+410.98%)
Mutual labels:  database, postgresql, postgres
Go Kallax
Kallax is a PostgreSQL typesafe ORM for the Go language.
Stars: ✭ 853 (+420.12%)
Mutual labels:  database, postgresql, postgres
Pg flame
A flamegraph generator for Postgres EXPLAIN ANALYZE output.
Stars: ✭ 1,391 (+748.17%)
Mutual labels:  database, postgresql, postgres
Ship Hold
data access framework for Postgresql on nodejs
Stars: ✭ 110 (-32.93%)
Mutual labels:  database, postgresql, postgres

pg_hashids, generate short unique ids from integers

Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers. It converts numbers like 347 into strings like “yr8”. You can also decode those ids back. This is useful in bundling several parameters into one or simply using them as short UIDs.

You can use hashids to hide primary keys in your database. I've used the extension on several production databases.

Tested PostgreSQL versions : 9.5.X and 9.6.X (Should work on older versions, just not tested)

It's using hashids.c under the hood. More information about hashids and it's implementations here: hashids.org

Installation

Make sure you have development packages installed for postgres and build tools in general.

make; sudo make install

Then in a psql session issue:

CREATE extension pg_hashids;

Update

Install as usual.

make; sudo make install

Then in a psql session issue:

ALTER EXTENSION pg_hashids UPDATE;

or

DROP EXTENSION pg_hashids;
CREATE EXTENSION pg_hashids;

Check

SELECT default_version, installed_version FROM pg_available_extensions WHERE name = 'pg_hashids';

Usage

Encoding

Returns a hash using the default alphabet and empty salt.

SELECT id_encode(1001); -- Result: jNl

Returns a hash using the default alphabet and supplied salt.

SELECT id_encode(1234567, 'This is my salt'); -- Result: Pdzxp

Returns a hash using the default alphabet, salt and minimum hash length.

SELECT id_encode(1234567, 'This is my salt', 10); -- Result: PlRPdzxpR7

Returns a hash using the supplied alphabet, salt and minimum hash length.

SELECT id_encode(1234567, 'This is my salt', 10, 'abcdefghijABCDxFGHIJ1234567890'); -- Result: 3GJ956J9B9

Decoding

You can also decode previouslt generated hashes. Just use the same salt, otherwise you'll get wrong results.

SELECT id_decode('PlRPdzxpR7', 'This is my salt', 10); -- Result: 1234567

Using a custom alphabet

SELECT id_decode('3GJ956J9B9', 'This is my salt', 10, 'abcdefghijABCDxFGHIJ1234567890'); -- Result: 1234567
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].