Package tipy :: Module db :: Class SqliteDatabaseConnector
[hide private]
[frames] | no frames]

Class SqliteDatabaseConnector

source code

       object --+    
                |    
DatabaseConnector --+
                    |
                   SqliteDatabaseConnector

Database connector for sqlite databases.

Class Hierarchy for SqliteDatabaseConnector
Class Hierarchy for SqliteDatabaseConnector

Instance Methods [hide private]
 
__init__(self, dbname, maxN=1)
SqliteDatabaseConnector creator.
source code
 
commit(self)
Send a commit to the database.
source code
 
open_database(self)
Open the database.
source code
 
close_database(self)
Close the database.
source code
list
execute_sql(self, query)
Execute a query string on an open database.
source code

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

    Inherited from DatabaseConnector
 
create_table_if_not_exists(self)
Create the database tables and indexes if they don't exists.
source code
 
crt_index(self, n)
Create the index for the table storing n-gram of given n.
source code
 
crt_ngram_table(self, n=1)
Creates a table in the database to store n-gram of a given n.
source code
 
dlt_index(self, n)
Drop the index for the table storing n-gram of given n.
source code
 
drop_ngram_table(self, n=1)
Drop a n-gram table in the database.
source code
 
extract_first_integer(self, table) source code
 
insert_ngram(self, ngram, count)
Insert an n-gram with its number of occurences into the database.
source code
 
make_select_like_clause(self, n) source code
 
make_values_clause(self, ngram, count) source code
 
make_where_clause(self, ngram) source code
 
make_where_like_clause(self, ngram) source code
int
ngram_count(self, ngram)
Retrieve the number of occurences of a given ngram in the database.
source code
list
ngram_table_tp(self, ngram, limit=-1)
Retrieve the n-gram records which complete the given n-gram.
source code
tuple
ngrams(self, withCounts=False)
Returns all ngrams that are in every tables of the database.
source code
int
ngrams_in_table(self, n)
Compute the number of n-grams in the n-grams table of given n.
source code
 
remove_ngram(self, ngram)
Remove a given ngram from the databae.
source code
int
sum_ngrams_occ(self, n)
Compute the occurences sum of every n-grams of given n in database.
source code
 
update_ngram(self, ngram, count)
Update an n-gram number of occurences in the database.
source code
Class Variables [hide private]
    Inherited from DatabaseConnector
  singleQuoteRegex = re.compile(r'\'')
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, dbname, maxN=1)
(Constructor)

source code 

SqliteDatabaseConnector creator.

Parameters:
  • dbname (str) - Path to the database file.
  • maxN (int) - The n in the longer database n-grams table.
Overrides: object.__init__

execute_sql(self, query)

source code 

Execute a query string on an open database.

Parameters:
  • query (str) - The query to execute.
Returns: list
The query result.