Package horizons :: Package util :: Module dbreader :: Class DbReader
[hide private]
[frames] | no frames]

Class DbReader

source code

Class that handles connections to sqlite databases

Instance Methods [hide private]
 
__init__(self, dbfile) source code
 
__call__(self, command, *args)
Executes a sql command.
source code
 
cached_query(self, command, *args)
Executes a sql command and saves its result in a dict.
source code
 
execute_many(self, command, parameters)
Executes a sql command for each sequence or mapping found in parameters.
source code
 
execute_script(self, script)
Executes a multiline script.
source code
 
close(self)
Closes the db
source code
Method Details [hide private]

__init__(self, dbfile)
(Constructor)

source code 
Parameters:
  • file - str containing the database file.

__call__(self, command, *args)
(Call operator)

source code 

Executes a sql command.

Parameters:
  • command - str containing the raw sql command, with ? as placeholders for values (eg. SELECT ? FROM ?). command must not end with ';', it's added automatically here.
  • args - tuple containing the values to add into the command.

cached_query(self, command, *args)

source code 

Executes a sql command and saves its result in a dict. @params, return: same as in __call__

Decorators:
  • @decorators.cachedmethod

execute_many(self, command, parameters)

source code 

Executes a sql command for each sequence or mapping found in parameters.

Parameters:
  • command - same as in __call__
  • parameters - sequence or iterator

execute_script(self, script)

source code 

Executes a multiline script.

Parameters:
  • script - multiline str containing an sql script.