Ravel Python API Reference
A Database-Defined Network Controller
Public Member Functions | List of all members
ravel.db.RavelDb Class Reference

A representation of Ravel's backend PostgreSQL database. More...

Public Member Functions

def __init__
 
def conn
 returns: a psycopg2 connection to the PostgreSQL database
 
def cursor
 
def num_connections
 Returns the number of existing connections to the database. More...
 
def init
 Initialize the database with the base Ravel SQL implementation. More...
 
def load_schema
 Load the specified schema into the database". More...
 
def load_topo
 Load a topology from the specified network provider. More...
 
def create
 If not created, create a database with the name specified in the constructor.
 
def add_extensions
 If not already added, add extensions required by Ravel (plpythonu, postgis, pgrouting)
 
def clean
 Clean the database of any existing Ravel components.
 
def truncate
 Clean the database of any state Ravel components, except for topology tables. More...
 

Detailed Description

A representation of Ravel's backend PostgreSQL database.

Constructor & Destructor Documentation

def ravel.db.RavelDb.__init__ (   self,
  name,
  user,
  base,
  passwd = None,
  reconnect = False 
)
Parameters
namethe name of the database to connect to
userthe username to use to connect
basea file containing the SQL implementation for Ravel's base
passwdthe password to connect to the database
reconnecttrue to connect to an existing database setup, false to load a new instance of Ravel's base into the database

Member Function Documentation

def ravel.db.RavelDb.cursor (   self)
Returns
a psycopg2 cursor from RavelDb.conn for the PostgreSQL database
def ravel.db.RavelDb.init (   self)

Initialize the database with the base Ravel SQL implementation.

Removes any existing Ravel objects from the database

def ravel.db.RavelDb.load_schema (   self,
  script 
)

Load the specified schema into the database".

Parameters
scriptpath to a SQL script
def ravel.db.RavelDb.load_topo (   self,
  provider 
)

Load a topology from the specified network provider.

Parameters
providera ravel.network.NetworkProvider instance
def ravel.db.RavelDb.num_connections (   self)

Returns the number of existing connections to the database.

If there are >1 connections, a new Ravel base implementation cannot be loaded into the database.

Returns
the number of existing connections to the database
def ravel.db.RavelDb.truncate (   self)

Clean the database of any state Ravel components, except for topology tables.

This rolls back the database to the state after the topology is first loaded


The documentation for this class was generated from the following file: