Esempio n. 1
0
import json
import lib

db = lib.db()
ws = lib.ws()


def setup():
    with db.cursor() as cur:
        cur.execute("""DELETE FROM classbook""")
        cur.execute("""DELETE FROM classbook_proposal""")
        cur.execute("""DELETE FROM classbook_localization""")
        cur.execute("""INSERT INTO classbook VALUES(
			 100, 0, 1, '098', '1f43f', 'test1', 'tefindme',
			 'md5md5md5md5md5md5md5md5md5md5md', 
			 '2017-10-10 10:10:10', '2017-10-10 10:10:10')""")
        cur.execute("""INSERT INTO classbook VALUES(
			 102, 0, 2, '098', '1f43f', 'test', 'test2',
			 'md5md5md5md5md5md5md5md5md5md5md',
			 '2017-10-10 10:10:10', '2017-10-10 10:10:10')""")
        cur.execute("""INSERT INTO classbook VALUES(
			 103, 0, 3, '098', '1f43f', 'tutsearch', 'test2',
			 'md5md5md5md5md5md5md5md5md5md5md',
			 '2017-10-10 10:10:10', '2017-10-10 10:10:10')""")
        cur.execute("""INSERT INTO classbook VALUES(
			 104, 100, 2, '098', '1f43f', 'test1test1', 'test1',
			 'md5md5md5md5md5md5md5md5md5md5md',
			 '2017-10-10 10:10:10', '2017-10-10 10:10:10')""")
        cur.execute("""INSERT INTO classbook_proposal VALUES(
			 105, 102, 'sdsd', 'en', 'proposal', "before", 'test1',
			 "before", 'md5md5md5md5md5md5md5md5md5md5md', NOW())""")
Esempio n. 2
0
try:
    import lib.db as db
    #Create a single db instance, accessed globally to save resources
    DB = db.db()
    l.DB_FIELD_DELIMITER_START = DB.literalDelimeterStart
    l.DB_FIELD_DELIMITER_END = DB.literalDelimeterEnd
except:
    logging.info(
        'Failed to import or connect to the DB, operating in offline mode. Obtaining delimiter from config file'
    )

    class db:
        literalDelimeterStart = config.get('db', 'delimeter_start')
        literalDelimeterEnd = config.get('db', 'delimeter_end')

    DB = db()


class viewFactory:
    '''
        view factory has 2 primary modes:
        1) DB Driven
            A) Prefetch -- This is fastest when you are generating many tables
            B) Query 1 Table -- This is simple when you are generating only a single table
        2) Looker API Driven
            Requires info schema to be modeled in Looker and available via the api connection configured in settings
            This has the added benefit that no drivers are required to be installed and therefore can work for any Looker DB connection
            **Might be slightly slower than direct DB connection for large numbers of tables
    '''
    def build_info_schema_odbc_prefetch(self,
                                        tablePattern=None,