Package BioSQL :: Module BioSeqDatabase :: Class DBServer
[hide private]
[frames] | no frames]

Class DBServer

source code

object --+
         |
        DBServer

Represents a BioSQL database continaing namespaces (sub-databases).

This acts like a Python dictionary, giving access to each namespace (defined by a row in the biodatabase table) as a BioSeqDatabase object.

Instance Methods [hide private]
 
__init__(self, conn, module, module_name=None)
Create a DBServer object.
source code
 
__repr__(self)
Return a short description of the class name and database connection.
source code
 
__getitem__(self, name)
Return a BioSeqDatabase object.
source code
 
__len__(self)
Return number of namespaces (sub-databases) in this database.
source code
 
__contains__(self, value)
Check if a namespace (sub-database) in this database.
source code
 
__iter__(self)
Iterate over namespaces (sub-databases) in the database.
source code
 
iterkeys(self)
Iterate over namespaces (sub-databases) in the database.
source code
 
itervalues(self)
Iterate over BioSeqDatabase objects in the database.
source code
 
iteritems(self)
Iterate over (namespace, BioSeqDatabase) in the database.
source code
 
keys(self)
List of namespaces (sub-databases) in the database.
source code
 
values(self)
List of BioSeqDatabase objects in the database.
source code
 
items(self)
List of (namespace, BioSeqDatabase) for entries in database.
source code
 
__delitem__(self, name)
Remove a namespace and all its entries.
source code
 
remove_database(self, db_name)
Remove a namespace and all its entries (OBSOLETE).
source code
 
new_database(self, db_name, authority=None, description=None)
Add a new database to the server and return it.
source code
 
load_database_sql(self, sql_file)
Load a database schema into the given database.
source code
 
commit(self)
Commit the current transaction to the database.
source code
 
rollback(self)
Roll-back the current transaction.
source code
 
close(self)
Close the connection. No further activity possible.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, conn, module, module_name=None)
(Constructor)

source code 

Create a DBServer object.

Arguments:
  • conn - A database connection object
  • module - The module used to create the database connection
  • module_name - Optionally, the name of the module. Default: module.__name__

Normally you would not want to create a DBServer object yourself. Instead use the open_database function, which returns an instance of DBServer.

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 
Return a short description of the class name and database connection.
Overrides: object.__repr__

__getitem__(self, name)
(Indexing operator)

source code 

Return a BioSeqDatabase object.

Arguments:
  • name - The name of the BioSeqDatabase

remove_database(self, db_name)

source code 

Remove a namespace and all its entries (OBSOLETE).

Try to remove all references to items in a database:

>>> server.remove_database(name)

In keeping with the dictionary interface, you can now do this:

>>> del server[name]

load_database_sql(self, sql_file)

source code 

Load a database schema into the given database.

This is used to create tables, etc when a database is first created. sql_file should specify the complete path to a file containing SQL entries for building the tables.