Exemplo n.º 1
0
def setup_module(module):
    print()
    set_dsn(sys='postgres', database="ci_test", host='localhost', user='******')
    schema = DBSchema()
    schema.add_module(module)
    schema.drop()
    schema.create()
Exemplo n.º 2
0
def command_init(cmd_args):

    from schema.db import create_dbuser, create_database, create_tables

    set_dsn(dsn='postgres', sys='postgres', host='localhost',  database="postgres", user='******')
    create_dbuser(username="******", password="******")
    create_database(database='alchemy', username='******')
    set_dsn(sys='postgres', host='localhost',  database="alchemy", user='******')
    create_tables()
    print('初始化数据库完成',)
Exemplo n.º 3
0
def load(homepath=None):

    if homepath is None:
        homepath = _get_home_path()
    
    print('homepath: ' + homepath)

    conf_dir = fp.join(homepath, 'conf')
    
    
    # 加载日志的配置文件
    import logging.config    
    conf_file = fp.join(conf_dir, 'logging.yaml')
    if fp.exists(conf_file):
        with open(conf_file) as f:
            conf = yaml.load(f)
        conf.setdefault('version', 1)
        logging.config.dictConfig(conf)
    # logging.basicConfig()

    _logger = logging.getLogger(__name__)
    _logger.info('configuration loaded, ' + conf_file) 

    abcs =logging.getLogger('abcs')

    abcs.info('test')
     
    conf_file = fp.join(conf_dir, 'database.yaml')
    if fp.exists(conf_file):
        with open(conf_file) as f:
            conf = yaml.load(f)
            for dsn, settings in conf.items():
                if dsn.upper() == 'DEFAULT':
                    dsn = 'DEFAULT'
                
                try:                
                    set_dsn(dsn=dsn, **settings)
                except Exception as ex:
                    _logger.error(str(ex), exc_info=True)

    _logger.info('configuration loaded, ' + conf_file)                       
Exemplo n.º 4
0
def setup_module(module):
    print()
    set_dsn(sys='postgres', database="ci_test", host='localhost', user='******')
Exemplo n.º 5
0
# -*- coding: utf-8 -*-

import pytest
import inspect
from datetime import datetime, date
from decimal import Decimal
from domainics.db import dtable
from domainics.domobj import dset, datt

from domainics.db import DBSchema, set_dsn, transaction, dbc, dmerge, drecall

set_dsn(sys='postgres', database="ci_test", host='localhost', user='******')


def setup_function(function):
    print()
    module = inspect.getmodule(function)

    schema = DBSchema()
    schema.add_module(module)
    schema.drop()
    schema.create()


class t_b(dtable):
    a = datt(int)
    b = datt(int)
    c = datt(int)
    d = datt(int)

    __dobject_key__ = [a, b]
Exemplo n.º 6
0
# -*- coding: utf-8 -*-

import pytest
import inspect
from datetime import datetime, date
from decimal import Decimal
from domainics.db import dtable
from domainics.domobj import dset, datt

from domainics.db import DBSchema, set_dsn, transaction, dbc, dmerge, drecall

set_dsn(sys='postgres', database="ci_test", host='localhost', user='******')



def setup_function(function):
    print()
    module = inspect.getmodule(function)

    schema = DBSchema()
    schema.add_module(module)
    schema.drop()
    schema.create()


class t_b(dtable):
    a = datt(int)
    b = datt(int)
    c = datt(int)
    d = datt(int)
Exemplo n.º 7
0
def setup_module(module):
    print()
    set_dsn(sys='postgres', database="ci_test", host='localhost', user='******')