{"id":16632738,"url":"https://github.com/benwebber/sqlite3-uuid","last_synced_at":"2025-03-21T15:31:27.524Z","repository":{"id":33347036,"uuid":"36991838","full_name":"benwebber/sqlite3-uuid","owner":"benwebber","description":"SQLite extension for generating UUIDs","archived":false,"fork":false,"pushed_at":"2018-08-19T14:48:33.000Z","size":33,"stargazers_count":47,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-18T02:44:17.720Z","etag":null,"topics":["extension","sqlite","sqlite3","uuid"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benwebber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-06T19:08:34.000Z","updated_at":"2025-02-27T08:48:51.000Z","dependencies_parsed_at":"2022-08-25T03:01:45.628Z","dependency_job_id":null,"html_url":"https://github.com/benwebber/sqlite3-uuid","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fsqlite3-uuid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fsqlite3-uuid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fsqlite3-uuid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fsqlite3-uuid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benwebber","download_url":"https://codeload.github.com/benwebber/sqlite3-uuid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244822653,"owners_count":20516144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","sqlite","sqlite3","uuid"],"created_at":"2024-10-12T05:10:04.317Z","updated_at":"2025-03-21T15:31:27.141Z","avatar_url":"https://github.com/benwebber.png","language":"C","readme":"# sqlite3-uuid\n\n[![Build Status](https://travis-ci.org/benwebber/sqlite3-uuid.svg?branch=master)](https://travis-ci.org/benwebber/sqlite3-uuid)\n[![codecov](https://codecov.io/gh/benwebber/sqlite3-uuid/branch/master/graph/badge.svg)](https://codecov.io/gh/benwebber/sqlite3-uuid)\n\nThis SQLite extension implements functions for creating [RFC 4122](https://www.ietf.org/rfc/rfc4122.txt) compliant UUIDs.\n\n## Installation\n\n1. Install the necessary development headers. Mac OS X ships with SQLite and the development headers, but you may need to install them on Linux.\n\n    * Debian / Ubuntu:\n\n        ```\n        sudo apt-get install libsqlite3-dev libssl-dev uuid-dev\n        ```\n\n    * Red Hat / CentOS:\n\n        ```\n        sudo yum install openssl-devel sqlite-devel uuid-devel\n        ```\n\n2. Build the extension. The build will produce a shared library for your platform under `dist/`.\n\n    ```\n    make\n    ```\n\n2. Load the extension using your SQLite API of choice. For example, in Python,\n\n    ```python\n    import sqlite3\n\n    con = sqlite3.connect(':memory:')\n\n    con.enable_load_extension(True)\n    con.load_extension('/path/to/uuid')\n    con.enable_load_extension(False)\n\n    for row in con.execute('SELECT uuid4();'):\n        print(row)\n    ```\n\n## Usage\n\n### `uuid1()`\n\nGenerate a version 1 UUID, based on the time and host machine's MAC address.\n\n```sql\nSELECT uuid1();\nd5a80b20-0d8f-11e5-b8cb-080027b6ec40\n```\n\n### `uuid3()`\n\nGenerate a version 3 (MD5) namespace UUID.\n\n```\nSELECT uuid3(uuid_ns_dns(), 'example.org');\n04738bdf-b25a-3829-a801-b21a1d25095b\n```\n\n### `uuid4()`\n\nGenerate a version 4 (random) UUID.\n\n```sql\nSELECT uuid4();\n1e607604-f360-4fa5-863a-bc91adc70bb9\n```\n\n### `uuid5()`\n\nGenerate a version 5 (SHA1) namespace UUID.\n\n```\nSELECT uuid3(uuid_ns_dns(), 'example.org');\naad03681-8b63-5304-89e0-8ca8f49461b5\n```\n\n### `uuid_nil()`\n\nGenerate the nil UUID.\n\n```\nSELECT uuid_nil();\n00000000-0000-0000-0000-000000000000\n```\n\n### Namespaces\n\n#### DNS\n\n```\nSELECT uuid_ns_dns();\n6ba7b810-9dad-11d1-80b4-00c04fd430c8\n```\n\n#### OID\n\n```\nSELECT uuid_ns_oid();\n6ba7b812-9dad-11d1-80b4-00c04fd430c8\n```\n\n#### URL\n\n```\nSELECT uuid_ns_url();\n6ba7b811-9dad-11d1-80b4-00c04fd430c8\n```\n\n#### X500\n\n```\nSELECT uuid_ns_x500();\n6ba7b814-9dad-11d1-80b4-00c04fd430c8\n```\n\n### Converting between types\n\n#### `uuid_to_blob()`\n\nConvert a TEXT UUID to a 16-byte BLOB.\n\n```\nsqlite3 -cmd '.load uuid' uuid.db 'SELECT uuid_to_blob(\"3dfe5c62-e543-46ff-a2e0-0b1017506be0\");' |\n  tr -d '\\n' |\n  hexdump -C\n00000000  3d fe 5c 62 e5 43 46 ff  a2 e0 0b 10 17 50 6b e0  |=.\\b.CF......Pk.|\n00000010\n```\n\n### `uuid_to_text()`\n\nConvert a 16-byte BLOB to a TEXT UUID.\n\n```\nSELECT uuid_to_text(uuid_to_blob('3dfe5c62-e543-46ff-a2e0-0b1017506be0'));\n3dfe5c62-e543-46ff-a2e0-0b1017506be0\n```\n\n## Notes\n\nThis extension only supports Linux and Mac OS X at the moment.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenwebber%2Fsqlite3-uuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenwebber%2Fsqlite3-uuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenwebber%2Fsqlite3-uuid/lists"}