示例#1
0
    def __init__(self,  driver=None, server=None, dbname = None, username=None, password=None, port=None,  **kwargs):

        '''Initialize the a database object
        
        Args:
            bundle. a Bundle object
            
            base_path. Path to the database file. If None, uses the name of the
            bundle, in the bundle build director. 
            
            post_create. A function called during the create() method. has
            signature post_create(database)
       
        '''
        self.driver = driver
        self.server = server
        self.dbname = dbname
        self.username = username
        self.password = password
   
        if port:
            self.colon_port = ':'+str(port)
        else:
            self.colon_port = ''
                
        self._engine = None

        self._connection = None


        self._table_meta_cache = {}

        self.dsn_template = self.DBCI[self.driver]
        self.dsn = self.dsn_template.format(user=self.username, password=self.password, 
                    server=self.server, name=self.dbname, colon_port=self.colon_port)
       
        self.logger = get_logger(__name__)
        self.logger.setLevel(logging.INFO) 
        
        self._unmanaged_session = None
示例#2
0
'''
Created on Sep 7, 2013

@author: eric
'''
"""
Copyright (c) 2013 Clarinova. This file is licensed under the terms of the
Revised BSD License, included in this distribution as LICENSE.txt
"""
from databundles.util import get_logger
import logging

logger = get_logger(__name__)
#logger.setLevel(logging.DEBUG)

class InserterInterface(object):
    
    def __enter__(self): raise NotImplemented()
    
    def __exit__(self, type_, value, traceback): raise NotImplemented()
    
    def insert(self, row, **kwargs): raise NotImplemented()
    
    def close(self): raise NotImplemented()

class UpdaterInterface(object):
    
    def __enter__(self): raise NotImplemented()
    
    def __exit__(self, type_, value, traceback): raise NotImplemented()