{"id":15442389,"url":"https://github.com/alanshaw/ipfs-ds-postgres","last_synced_at":"2025-04-28T17:22:03.036Z","repository":{"id":66220853,"uuid":"261259856","full_name":"alanshaw/ipfs-ds-postgres","owner":"alanshaw","description":"🐘 PostgreSQL datastore for IPFS","archived":false,"fork":false,"pushed_at":"2022-01-14T12:51:44.000Z","size":32,"stargazers_count":11,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T08:02:01.871Z","etag":null,"topics":["ipfs","libp2p","postgres","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alanshaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-04T18:07:37.000Z","updated_at":"2024-06-04T14:37:23.000Z","dependencies_parsed_at":"2023-02-22T02:00:32.135Z","dependency_job_id":null,"html_url":"https://github.com/alanshaw/ipfs-ds-postgres","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanshaw%2Fipfs-ds-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanshaw%2Fipfs-ds-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanshaw%2Fipfs-ds-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanshaw%2Fipfs-ds-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alanshaw","download_url":"https://codeload.github.com/alanshaw/ipfs-ds-postgres/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251352746,"owners_count":21575879,"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":["ipfs","libp2p","postgres","sql"],"created_at":"2024-10-01T19:27:14.799Z","updated_at":"2025-04-28T17:22:03.020Z","avatar_url":"https://github.com/alanshaw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ipfs-ds-postgres\n\n[![Build Status](https://travis-ci.org/alanshaw/ipfs-ds-postgres.svg?branch=master)](https://travis-ci.org/alanshaw/ipfs-ds-postgres)\n[![Coverage](https://codecov.io/gh/alanshaw/ipfs-ds-postgres/branch/master/graph/badge.svg)](https://codecov.io/gh/alanshaw/ipfs-ds-postgres)\n[![Standard README](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme)\n[![GoDoc](http://img.shields.io/badge/godoc-reference-5272B4.svg)](https://godoc.org/github.com/alanshaw/ipfs-ds-postgres)\n[![golang version](https://img.shields.io/badge/golang-%3E%3D1.14.0-orange.svg)](https://golang.org/)\n[![Go Report Card](https://goreportcard.com/badge/github.com/alanshaw/ipfs-ds-postgres)](https://goreportcard.com/report/github.com/alanshaw/ipfs-ds-postgres)\n\n\u003e An implementation of [the datastore interface](https://github.com/ipfs/go-datastore) for PostgreSQL that uses the [pgx](https://github.com/jackc/pgx) PostgreSQL driver.\n\n**Note: Currently implements `Datastore` and `Batching` interfaces.**\n\n## Install\n\n```sh\ngo get github.com/alanshaw/ipfs-ds-postgres\n```\n\n## Usage\n\nEnsure a database is created and a table exists that has the following structure (replacing `table_name` with the name of the table the datastore will use - by default this is `blocks`):\n\n```sql\nCREATE TABLE IF NOT EXISTS table_name (key TEXT NOT NULL UNIQUE, data BYTEA)\n```\n\nIt's recommended to create a `text_pattern_ops` index on the table:\n\n```sql\nCREATE INDEX IF NOT EXISTS table_name_key_text_pattern_ops_idx ON table_name (key text_pattern_ops)\n```\n\nImport and use in your application:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\tpgds \"github.com/alanshaw/ipfs-ds-postgres\"\n)\n\nconst (\n\tconnString = \"postgresql://user:pass@host:12345/database?sslmode=require\"\n\ttableName  = \"blocks\" // (default)\n)\n\nfunc main() {\n\tds, err := pgds.NewDatastore(context.Background(), connString, pgds.Table(tableName))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n## API\n\n[GoDoc Reference](https://godoc.org/github.com/alanshaw/ipfs-ds-postgres)\n\n## Contribute\n\nFeel free to dive in! [Open an issue](https://github.com/alanshaw/ipfs-ds-postgres/issues/new) or submit PRs.\n\n## License\n\n[MIT](LICENSE) © Alan Shaw\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanshaw%2Fipfs-ds-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falanshaw%2Fipfs-ds-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanshaw%2Fipfs-ds-postgres/lists"}