diff options
| author | LV-426 <lv-426@taproot.org.il> | 2014-10-21 19:57:38 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2014-10-21 19:57:38 +0200 |
| commit | a48c2f33fe91cfb2645013b0174e7ce0e94a04b9 (patch) | |
| tree | 047fd557b7616b6664c5558969ccbe25c22decc9 /src-py/db_controller.py | |
| parent | 8d35498c06d3e832bdbcad2916efe2df9b23492d (diff) | |
mv DB_Driver classes to their own file
Diffstat (limited to 'src-py/db_controller.py')
| -rw-r--r-- | src-py/db_controller.py | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/src-py/db_controller.py b/src-py/db_controller.py index ceb5267c..84c0743e 100644 --- a/src-py/db_controller.py +++ b/src-py/db_controller.py @@ -316,89 +316,6 @@ class DBO_match_link_id_set(DB_op): self.add_statement(q, q_params) -class DB_Driver_Base(): - pass - -class DB_Driver_Embedded(DB_Driver_Base): - def __init__(self, db_base_url): - self.tx_base_url = db_base_url + '/db/data/transaction' - - from org.rhizi.db.neo4j.util import EmbeddedNeo4j - self.edb = EmbeddedNeo4j.createDb() - self.edb.createDb() - - def begin_tx(self, op): - pass - - def exec_statement_set(self, op): - s_set = op.statement_set - self.edb.executeCypherQury() - - def commit_tx(self, op): - pass - - def log_committed_queries(self, statement_set): - for sp_dict in statement_set['statements']: - log.debug('\tq: {0}'.format(sp_dict['statement'])) - -class DB_Driver_REST(DB_Driver_Base): - def __init__(self, db_base_url): - self.tx_base_url = db_base_url + '/db/data/transaction' - - def begin_tx(self, op): - tx_open_url = self.tx_base_url - - try: - # - # [!] neo4j seems picky about receiving an additional empty statement list - # - data = data = db_util.statement_set_to_REST_form([]) - ret = db_util.post_neo4j(tx_open_url, data) - tx_commit_url = ret['commit'] - op.parse_tx_id(tx_commit_url) - - log.debug('tx-open: id: {0}, commit-url: {1}'.format(op.tx_id, tx_commit_url)) - except Exception as e: - raise Exception('failed to open transaction:' + e.message) - - def exec_statement_set(self, op): - - tx_url = "{0}/{1}".format(self.tx_base_url, op.tx_id) - statement_set = db_util.statement_set_to_REST_form(op.statement_set) - - try: - post_ret = db_util.post_neo4j(tx_url, statement_set) - op.result_set = post_ret['results'] - op.error_set = post_ret['errors'] - if 0 != len(op.error_set): - raise Neo4JException(op.error_set) - - self.log_committed_queries(statement_set) - except Neo4JException as e: - raise e - except Exception as e: - raise Exception('failed exec op statements: err: {0}, url: {1}'.format(e.message, tx_url)) - - def commit_tx(self, op): - tx_commit_url = "{0}/{1}/commit".format(self.tx_base_url, op.tx_id) - - try: - # - # [!] neo4j seems picky about receiving an additional empty statement list - # - data = db_util.statement_set_to_REST_form([]) - ret = db_util.post(tx_commit_url, data) - - log.debug('tx-commit: id: {0}, commit-url: {1}'.format(op.tx_id, tx_commit_url)) - - return ret - except Exception as e: - raise Exception('failed to commit transaction:' + e.message) - - def log_committed_queries(self, statement_set): - for sp_dict in statement_set['statements']: - log.debug('\tq: {0}'.format(sp_dict['statement'])) - class DB_Controller: """ neo4j DB controller |
