Fun with PWM  0.32
DB.Table Class Reference

SQLite Table abstraction. More...

Inheritance diagram for DB.Table:
Setting.Setting

Public Member Functions

def __init__ (self, dbpath='app.db', tname=None, primary='rowid', cols={})
 
def parseAttributes (self, omit=[])
 
def check (self)
 
def query (self, expr='', order='', keyindex=False)
 
def getSqlName (self)
 
def getPrimaryKey (self)
 
def getColList (self, addprimary=True)
 
def save (self)
 
def load (self, index)
 
def reload (self)
 
def loadBy (self, wheres={})
 
def delete (self)
 

Public Attributes

 db
 

Detailed Description

SQLite Table abstraction.

Constructor & Destructor Documentation

§ __init__()

def DB.Table.__init__ (   self,
  dbpath = 'app.db',
  tname = None,
  primary = 'rowid',
  cols = {} 
)
Initializes the Table object
a generic object used to map object attributes directly to SQLite columns

@param dbpath
@param tname
@param primary
@param cols

Member Function Documentation

§ check()

def DB.Table.check (   self)
confirms the table corresponding to this object is present. if not, create it.

§ delete()

def DB.Table.delete (   self)
removes a row from the SQLite database

§ getColList()

def DB.Table.getColList (   self,
  addprimary = True 
)
Gets a list of column names

@param addprimary

@return list containing the current columns

§ getPrimaryKey()

def DB.Table.getPrimaryKey (   self)
Gets the primary key column name

@return str

§ getSqlName()

def DB.Table.getSqlName (   self)
Gets the SQLite table name

@return str

§ load()

def DB.Table.load (   self,
  index 
)
loads the values from the SQLite database into corresponding attributes

@param index

§ loadBy()

def DB.Table.loadBy (   self,
  wheres = {} 
)
like load but an expression can be provided

@param wheres

@return dict or None

§ parseAttributes()

def DB.Table.parseAttributes (   self,
  omit = [] 
)
nominates attributes based on their data type

@param omit

§ query()

def DB.Table.query (   self,
  expr = '',
  order = '',
  keyindex = False 
)
run a select query on this table and return the results in the form of instances of this object

@param expr
@param order
@param keyindex

@return dict

§ save()

def DB.Table.save (   self)
commits the values of the current attributes to the SQLite database

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