pylogeny.database module
Connect, access, + manipulate external tree data from a remote SQL server or
from an sqlite file.
-
class pylogeny.database.DatabaseLandscape(ali, starting_tree=None, root=True, operator='SPR')[source]
Bases: pylogeny.landscape.landscape
Abstract the landscape to one comprising a database.
-
getNode(i)[source]
-
class pylogeny.database.SQLDatabase(host, user, pw, db)[source]
Bases: pylogeny.database.database
Database object to allow reading from a MySQL database.
-
__init__(host, user, pw, db)[source]
-
close()[source]
-
connect()[source]
-
getColumns(table)[source]
Return column information for a given table.
-
getTables()[source]
-
query(q)[source]
-
querymany(q, i)[source]
-
class pylogeny.database.SQLExhaustiveLandscape(dbobj, aliname)[source]
Bases: pylogeny.database.DatabaseLandscape
Abstract the landscape to one comprising an SQL database.
-
__init__(dbobj, aliname)[source]
Instantiate this landscape.
| Parameters: |
- dbobj (a database) – a database object
- aliname (a string) – the name of the alignment (table in the database)
|
-
exploreRandomTree(i)[source]
-
exploreTree(i)[source]
-
getDatabaseNode(i)[source]
-
class pylogeny.database.SQLiteDatabase(filepath)[source]
Bases: pylogeny.database.database
-
__init__(filepath)[source]
Instantiate this SQLite database object.
| Parameters: | filepath (a string) – a path to the file |
-
close()[source]
-
getColumns(table)[source]
Return column information for a given table.
| Parameters: | table (a string) – a table name |
-
getTables()[source]
-
query(q)[source]
-
querymany(q, i)[source]
-
class pylogeny.database.SQLiteLandscape(dbobj)[source]
Bases: pylogeny.landscape.landscape
Allow random access of all landscape data from an sqlite file found on
the hard disk.
-
__init__(dbobj)[source]
-
class pylogeny.database.database[source]
Bases: object
Allow interfacing with a SQL/sqlite database.
-
__init__()[source]
-
close()[source]
-
filterRecords(table, condn)[source]
Get all records from a given table following a condition. The
equivalent of calling “SELECT * FROM table WHERE cond”.
| Parameters: |
- table (a string) – a table name
- condn (a string) – a condition in SQL syntax
|
| Returns: | a list of tuples
|
-
getColumns(table)[source]
Get only header names for a given table’s columns.
| Parameters: | table (a string) – a table name |
-
getRecords(table)[source]
Get all records from a given table in the database. The
equivalent of a call “SELECT * FROM table”.
| Parameters: | table (a string) – a table name |
| Returns: | a list of tuples |
-
getRecordsAsDict(table)[source]
Acquires records using getRecords() and then leverages
access using a dictionary data structure where keys are
headers (column names).
| Parameters: | table (a string) – a table name |
| Returns: | a dictionary (of records as values) |
-
getRecordsColumn(table, col)[source]
Get all data for a single column from records for a table. The
equivalent of a call “SELECT col FROM table”.
| Parameters: |
- table (a string) – a table name
- col (a string) – a column name
|
| Returns: | a list of strings
|
-
getTables()[source]
-
insertRecord(tablename, record)[source]
Insert a single record.
| Parameters: |
- tablename (a string) – the name of the table
- record (a tuple) – a tuple
|
-
insertRecords(tablename, items)[source]
Insert a number of records into a table.
| Parameters: |
- tablename (a string) – the name of the table
- items (a list of tuples) – a list of record tuples
|
-
isEmpty()[source]
Determine if the database is empty.
-
iterRecords(table)[source]
Get a record, one at a time, from a table in the database.
| Parameters: | table (a string) – a table name |
| Returns: | a generator of records |
-
newTable(tablename, *args)[source]
Create a new table.
| Parameters: | tablename (a string) – the name of this table |
-
query(q)[source]
-
querymany(q, i)[source]