database

package
v0.0.0-...-07e8905 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDatabase

func ClearDatabase(db *sql.DB, schema *Schema) error

ClearDatabase removes all data from the SQLite database keeping the schema.

func CreateDatabase

func CreateDatabase(filename string, removeExisting bool) (*sql.DB, error)

CreateDatabase creates a new SQLite database file, removing the existing file if needed.

func CreateDatabaseSchema

func CreateDatabaseSchema(db *sql.DB, schema *Schema) (*sql.Result, error)

CreateDatabaseSchema creates the given schema in the SQLite database.

func DeleteDatabase

func DeleteDatabase(filename string) error

DeleteDatabase deletes the given SQLite database file.

func GetDatabaseConnection

func GetDatabaseConnection(filename string) (*sql.DB, error)

GetDatabaseConnection returns a connection to the SQLite database.

Types

type Column

type Column struct {
	Name        string // Column name
	Type        string // Data type (e.g., INTEGER, VARCHAR, etc.)
	Constraints string // Constraints (e.g., NOT NULL, PRIMARY KEY, etc.)
}

Column represents a single column in a table schema.

type Schema

type Schema struct {
	Tables  map[string]Table // List of tables
	Indexes []string         // List of indexes
}

Schema represents a schema of a database.

func GetSchema

func GetSchema() *Schema

func (*Schema) GenerateSchemaQuery

func (s *Schema) GenerateSchemaQuery() string

GenerateSchemaQuery generates the SQL CREATE TABLE statements from the Schema struct.

func (*Schema) GetTableNames

func (s *Schema) GetTableNames() []string

GetTableNames returns the list of table names in the schema.

type Synchronization

type Synchronization struct {
	API *peeringdb.API
	DB  *sql.DB
}

Synchronization is a structure holding pointers to the PeeringDB API and database being used.

func (*Synchronization) SynchronizeCampuses

func (s *Synchronization) SynchronizeCampuses(bar *mpb.Bar)

func (*Synchronization) SynchronizeCarrierFacilities

func (s *Synchronization) SynchronizeCarrierFacilities(bar *mpb.Bar)

func (*Synchronization) SynchronizeCarriers

func (s *Synchronization) SynchronizeCarriers(bar *mpb.Bar)

func (*Synchronization) SynchronizeFacilities

func (s *Synchronization) SynchronizeFacilities(bar *mpb.Bar)

func (*Synchronization) SynchronizeInternetExchangeFacilities

func (s *Synchronization) SynchronizeInternetExchangeFacilities(bar *mpb.Bar)

func (*Synchronization) SynchronizeInternetExchangeLANs

func (s *Synchronization) SynchronizeInternetExchangeLANs(bar *mpb.Bar)

func (*Synchronization) SynchronizeInternetExchangePrefixes

func (s *Synchronization) SynchronizeInternetExchangePrefixes(bar *mpb.Bar)

func (*Synchronization) SynchronizeInternetExchanges

func (s *Synchronization) SynchronizeInternetExchanges(bar *mpb.Bar)

func (*Synchronization) SynchronizeNetworkContacts

func (s *Synchronization) SynchronizeNetworkContacts(bar *mpb.Bar)

func (*Synchronization) SynchronizeNetworkFacilities

func (s *Synchronization) SynchronizeNetworkFacilities(bar *mpb.Bar)

func (*Synchronization) SynchronizeNetworkInternetExchangeLANs

func (s *Synchronization) SynchronizeNetworkInternetExchangeLANs(bar *mpb.Bar)

func (*Synchronization) SynchronizeNetworks

func (s *Synchronization) SynchronizeNetworks(bar *mpb.Bar)

func (*Synchronization) SynchronizeOrganizations

func (s *Synchronization) SynchronizeOrganizations(bar *mpb.Bar)

type Table

type Table struct {
	Name                  string   // Table name
	Columns               []Column // List of columns
	UniquenessConstraints []string // List of uniqueness constraints
}

Table represents a schema of a table.

func (*Table) GetColumnsNames

func (t *Table) GetColumnsNames() []string

GetColumnsNames returns the list of column names in the table without the "id" one.

Jump to

Keyboard shortcuts

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