Giter Club home page Giter Club logo

ipfs-ds-postgres's Introduction

ipfs-ds-postgres

Build Status Coverage Standard README GoDoc golang version Go Report Card

An implementation of the datastore interface for PostgreSQL that uses the pgx PostgreSQL driver.

Note: Currently implements Datastore and Batching interfaces.

Install

go get github.com/ipfs/ipfs-ds-postgres

Usage

Ensure 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):

CREATE TABLE IF NOT EXISTS table_name (key TEXT NOT NULL UNIQUE, data BYTEA)

It's recommended to create a text_pattern_ops index on the table:

CREATE INDEX IF NOT EXISTS table_name_key_text_pattern_ops_idx ON table_name (key text_pattern_ops)

Import and use in your application:

package main

import (
	"context"
	pgds "github.com/alanshaw/ipfs-ds-postgres"
)

const (
	connString = "postgresql://user:pass@host:12345/database?sslmode=require"
	tableName  = "blocks" // (default)
)

func main() {
	ds, err := pgds.NewDatastore(context.Background(), connString, pgds.Table(tableName))
	if err != nil {
		panic(err)
	}
}

API

GoDoc Reference

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT ยฉ Alan Shaw

ipfs-ds-postgres's People

Contributors

alanshaw avatar guseggert avatar petar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.