datastore

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package datastore contains configuration options, and functions to create a books' database before running the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(datasetPath string, config *Config, overwriteIfExists bool) error

New creates a new datastore to be used by the server. The datastore is created at the path specified by config (Dir + Name). overwriteIfExists specifies what to do if a datastore with the same path exists. The datastore is created using dataset at the specified path. Dataset should be a csv file with the following columns (id, title, authors, averageRating, isbn, isbn13, languageCode, pages, ratingsCount, textReviewsCount) in this order. The dataset is processed line by line and corrupt lines (wrong data types, incorrect number of columns, extra commas, etc..) are skipped (and logged). See https://www.kaggle.com/jealousleopard/goodreadsbooks

func Open

func Open(config *Config) (*sql.DB, error)

Open opens a connection to a database specified by given configuration.

Types

type Config

type Config struct {
	Driver string // DBMS's driver.

	Dir       string // Directory containing the datastore.
	Datastore string // Datastore's name.
	BookTable string // Table containing books.
}

Config holds datastore's configuration options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL