示例#1
0
def initialize(config=None):
    global _config, _initialized
    if _initialized:
        return
        
    if config is not None:
        _config = config

    logger.info('------start up------')
    _initialized = crane.initialize_storage(_config)
    return _initialized
示例#2
0
def initialize(config=None):
    global _config, _initialized
    if _initialized:
        return

    if config is not None:
        _config = config

    logger.info('------start up------')
    _initialized = crane.initialize_storage(_config)
    return _initialized
示例#3
0
import psycopg2
import psycopg2.extras
#from psycopg2.extensions import AsIs

import crane

ContractTable = "contract"
TurtleTable = "turtle"

t = os.path.join(os.path.dirname(__file__), '..\\monk_config.yml')

with open(t, 'r') as yf:
    config = yaml.load(yf)
    #con = psycopg2.connect("dbname={0} user={1}".format(config['dbname'], config['user']))
    crane.initialize_storage(config)


#===========================================
#===========================================
def getTableEntryById(category, targetId):

    executeString = "SELECT * FROM {0} WHERE id = {1}".format(
        category, targetId)
    try:
        cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
        cur.execute(executeString)

        row = cur.fetchone()
        if row is not None:
            return dict(row)
示例#4
0
文件: api.py 项目: ctchu/monkBackend
import psycopg2
import psycopg2.extras
#from psycopg2.extensions import AsIs

import crane

ContractTable = "contract"
TurtleTable = "turtle"

t = os.path.join(os.path.dirname(__file__), '..\\monk_config.yml')
        
with open(t, 'r') as yf:
    config = yaml.load(yf)
    #con = psycopg2.connect("dbname={0} user={1}".format(config['dbname'], config['user']))    
    crane.initialize_storage(config)
            
#===========================================
#===========================================
def getTableEntryById(category, targetId):
    
    executeString = "SELECT * FROM {0} WHERE id = {1}".format(category, targetId)
    try:
        cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)    
        cur.execute(executeString)
        
        row = cur.fetchone()
        if row is not None:            
            return dict(row)
        else:
            return None