The pyp_db Module

pyp_db contains a set of procedures for ...

Module Contents

createPedigreeDatabase(dbname='pypedal') ⇒ integer [#]

createPedigreeDatabase() creates a new database in SQLite.

dbname
The name of the database to create.
Returns:
A 1 on successful database creation, a 0 otherwise.

createPedigreeTable(curs, tablename='example') ⇒ integer [#]

createPedigreeDatabase() creates a new pedigree table in a SQLite database.

tablename
The name of the table to create.
Returns:
A 1 on successful table creation, a 0 otherwise.

databaseQuery(sql, curs=0, dbname='pypedal') ⇒ string [#]

databaseQuery() executes an SQLite query. This is a wrapper function used by the reporting functions that need to fetch data from SQLite. I wrote it so that any changes that need to be made in the way PyPedal talks to SQLite will only need to be changed in one place.

sql
A string containing an SQL query.
_curs
An [optional] SQLite cursor.
dbname
The database into which the pedigree will be loaded.
Returns:
The results of the query, or 0 if no resultset.

getCursor(dbname='pypedal') ⇒ cursor [#]

getCursor() creates a database connection and returns a cursor on success or a 0 on failure. It isvery useful for non-trivial queries because it creates SQLite aggrefates before returning the cursor. The reporting routines in pyp_reports make heavy use of getCursor().

dbname
The database into which the pedigree will be loaded.
Returns:
An SQLite cursor if the database exists, a 0 otherwise.

loadPedigreeTable(pedobj) ⇒ integer [#]

loadPedigreeDatabase() takes a PyPedal pedigree object and loads the animal records in that pedigree into an SQLite table.

pedobj
A PyPedal pedigree object.
dbname
The database into which the pedigree will be loaded.
tablename
The table into which the pedigree will be loaded.
Returns:
A 1 on successful table load, a 0 otherwise.

PypMean() (class) [#]

PypMean is a user-defined aggregate for SQLite for returning means from queries.

For more information about this class, see The PypMean Class.

PypSSD() (class) [#]

PypSSD is a user-defined aggregate for SQLite for returning sample standard deviations from queries.

For more information about this class, see The PypSSD Class.

PypSum() (class) [#]

PypSum is a user-defined aggregate for SQLite for returning sums from queries.

For more information about this class, see The PypSum Class.

PypSVar() (class) [#]

PypSVar is a user-defined aggregate for SQLite for returning sample variances from queries.

For more information about this class, see The PypSVar Class.

tableCountRows(dbname='pypedal', tablename='example') ⇒ integer [#]

tableCountRows() returns the number of rows in a table.

dbname
The database into which the pedigree will be loaded.
tablename
The table into which the pedigree will be loaded.
Returns:
The number of rows in the table 1 or 0.

tableDropRows(dbname='pypedal', tablename='example') ⇒ integer [#]

tableDropRows() drops all of the data from an existing table.

dbname
The database into which the pedigree will be loaded.
tablename
The table into which the pedigree will be loaded.
Returns:
A 1 if the data were dropped, a 0 otherwise.

tableExists(dbname='pypedal', tablename='example') ⇒ integer [#]

tableExists() queries the sqlite_master view in an SQLite database to determine whether or not a table exists.

dbname
The database into which the pedigree will be loaded.
tablename
The table into which the pedigree will be loaded.
Returns:
A 1 if the table exists, a 0 otherwise.

The PypMean Class

PypMean() (class) [#]

PypMean is a user-defined aggregate for SQLite for returning means from queries.

The PypSSD Class

PypSSD() (class) [#]

PypSSD is a user-defined aggregate for SQLite for returning sample standard deviations from queries.

The PypSum Class

PypSum() (class) [#]

PypSum is a user-defined aggregate for SQLite for returning sums from queries.

The PypSVar Class

PypSVar() (class) [#]

PypSVar is a user-defined aggregate for SQLite for returning sample variances from queries.