Exemplo n.º 1
0
def before_first():
    logWarning('Handling database init')
    if application.debug:
        # Debug/local dev
        logWarning('Debug Mode: MongoDB')
        default_database(Database( 'mongodb', mongo_url='mongodb://localhost:27017/TestDB'))
    else:
        # Production!
       logWarning('Production Mode: MongoDB')
       default_database(Database( 'mongodb', mongo_url='mongodb://localhost:27017/TestDB'))
    set_db_application_prefix(APPLICATION_NAME)

    # Make sure we have our tables
    #IncomingMessage.ensure_table()
    initDerivedDataTables()
def before_first():
    logWarning('Handling database init')
    if application.debug:
        # Debug/local dev
        logWarning('Debug Mode: MongoDB')
        default_database(Database( 'mongodb', mongo_url='mongodb://localhost:27017/TestDB'))
    else:
        # Production!
        logWarning('Production Mode: DynamoDB')
        default_database(Database('dynamodb'))
    set_db_application_prefix(APPLICATION_NAME)

    # Make sure we have our tables
    #IncomingMessage.ensure_table()
    initDerivedDataTables()
Exemplo n.º 3
0
def before_first():
    app_logger().info('Handling database init')

    if application.debug:
        # Debug/local dev
        default_database(Database('sqlite', filename=project_file('.test.db')))
    else:
        # Production!
        default_database(Database('dynamodb'))

    # Make sure we have our tables
    User.ensure_table()
    Transcript.ensure_table()
    Taxonomy.ensure_table()

    # Some debug data we might find useful
    if application.debug:
        TEST_EMAIL = application.config.get('TEST_EMAIL')
        me = first(User.find_by_index('idx_email', TEST_EMAIL))
        if not me:
            me = User(name='Test User', email=TEST_EMAIL)
            me.save()

        if not Transcript.find_all():
            ts1 = Transcript.from_xml_file(
                project_file('test/sample/SampleTranscript.xml')
            )
            ts1.script_identifier = 'Original Owned'
            ts1.owner = me.id
            ts1.tagger = ''
            ts1.id = ''
            ts1.save()

            ts2 = Transcript.from_xml_file(
                project_file('test/sample/SampleTranscript.xml')
            )
            ts2.script_identifier = 'New Assigned'
            ts2.owner = me.id
            ts2.tagger = me.id
            ts2.source_transcript = ts1.id
            ts2.id = ''  # Ensure new id on save
            ts2.save()
Exemplo n.º 4
0
from gludb.simple import DBObject, Field


@DBObject(table_name='MyDataTable')
class MyData(object):
    name = Field('')
    descrip = Field('')


##############################################################################
# Config

from gludb.config import default_database, Database

default_database(Database('sqlite', filename=':memory:'))
MyData.ensure_table()

# A little extra config - we need some records!
MyData(name='Alice', descrip='A Person').save()
MyData(name='Bob', descrip='Another Person').save()

##############################################################################
# Our backup script

from gludb.backup import Backup


def main():
    AWS_ACCESS_KEY = 'Enter-Yours-Here'
    AWS_SECRET_KEY = 'Enter-Yours-Here'
from gludb.simple import DBObject, Field


@DBObject(table_name='MyDataTable')
class MyData(object):
    name = Field('')
    descrip = Field('')


##############################################################################
# Config

from gludb.config import default_database, Database

default_database(Database('sqlite', filename=':memory:'))
MyData.ensure_table()

# A little extra config - we need some records!
MyData(name='Alice', descrip='A Person').save()
MyData(name='Bob', descrip='Another Person').save()


##############################################################################
# Our backup script

from gludb.backup import Backup


def main():
    AWS_ACCESS_KEY = 'Enter-Yours-Here'