コード例 #1
0
ファイル: shardpy.py プロジェクト: RobertMarton/shard.py
 def gen_db(self, node_cfg):
     pool_policy = node_cfg.get('pool_policy', 'default')
     node_cfg['pooling'], node_cfg['dbn'] = True, 'mysql'
     node_cfg.update(_pool_policy[pool_policy])
     if 'port' in node_cfg:
         node_cfg['port'] = int(node_cfg['port'])
     else:
         node_cfg['port'] = 3306
     return database(**{k:v for k, v in node_cfg.items() if k not in _config_fields})
コード例 #2
0
ファイル: shardpy.py プロジェクト: qizhoumeng/shard.py
 def gen_db(self, node_cfg):
     pool_policy = node_cfg.get('pool_policy', 'default')
     node_cfg['pooling'], node_cfg['dbn'] = True, 'mysql'
     node_cfg.update(_pool_policy[pool_policy])
     if 'port' in node_cfg:
         node_cfg['port'] = int(node_cfg['port'])
     else:
         node_cfg['port'] = 3306
     return database(
         **{k: v
            for k, v in node_cfg.items() if k not in _config_fields})
コード例 #3
0
ファイル: auctionDb.py プロジェクト: javi7/AuctionBeta
UPDATE_NFL_PLAYER_WKAL_POINTS = 'UPDATE t_nfl_players SET player_wkal_points = $points ' +\
								'WHERE player_id=$playerId'

SELECT_NFL_PLAYER_TOTAL_POINTS = 'SELECT SUM(total_pts) AS total_pts FROM t_performances WHERE player_id=$playerId'

UPDATE_ADD_USER_WIN = 'UPDATE t_site_users SET user_wins = user_wins + 1 WHERE user_id=$userId'
UPDATE_ADD_USER_LOSS = 'UPDATE t_site_users SET user_losses = user_losses + 1 WHERE user_id=$userId'
UPDATE_ADD_USER_TIE = 'UPDATE t_site_users SET user_ties = user_ties + 1 WHERE user_id=$userId'
UPDATE_USER_POINTS_FOR = 'UPDATE t_site_users SET user_points_for = user_points_for + $points WHERE user_id=$userId'

SELECT_USERS_FOR_STANDINGS = 'SELECT * FROM t_site_users ORDER BY user_division DESC, user_wins DESC, user_points_for DESC'

SELECT_ALL_LINEUP_PLAYERS = 'SELECT player_id, user_id, bid_amount, player_position FROM t_lineup_players NATURAL JOIN t_lineups ' + \
							' NATURAL JOIN t_bids NATURAL JOIN t_nfl_players WHERE week_id=$weekId'

dbase = db.database(dbn='mysql', db='AuctionBeta', user='******')

def query(queryString, queryParams):
	return dbase.query(queryString, vars=queryParams)

def register(username, password, email):
	password = sha256_crypt.encrypt(password)
	query(INSERT_NEW_USER, {
		'username': username, 'password': password, 'email':email
	})
	return True

def login(username, password):
	userResult = query(SELECT_USER_FROM_ALIAS_OR_EMAIL, {'username': username})
	if len(userResult) == 1:
		user = userResult[0]
コード例 #4
0
UPDATE_NFL_PLAYER_WKAL_POINTS = 'UPDATE t_nfl_players SET player_wkal_points = $points ' +\
        'WHERE player_id=$playerId'

SELECT_NFL_PLAYER_TOTAL_POINTS = 'SELECT SUM(total_pts) AS total_pts FROM t_performances WHERE player_id=$playerId'

UPDATE_ADD_USER_WIN = 'UPDATE t_site_users SET user_wins = user_wins + 1 WHERE user_id=$userId'
UPDATE_ADD_USER_LOSS = 'UPDATE t_site_users SET user_losses = user_losses + 1 WHERE user_id=$userId'
UPDATE_ADD_USER_TIE = 'UPDATE t_site_users SET user_ties = user_ties + 1 WHERE user_id=$userId'
UPDATE_USER_POINTS_FOR = 'UPDATE t_site_users SET user_points_for = user_points_for + $points WHERE user_id=$userId'

SELECT_USERS_FOR_STANDINGS = 'SELECT * FROM t_site_users ORDER BY user_division DESC, user_wins DESC, user_points_for DESC'

SELECT_ALL_LINEUP_PLAYERS = 'SELECT player_id, user_id, bid_amount, player_position FROM t_lineup_players NATURAL JOIN t_lineups ' + \
       ' NATURAL JOIN t_bids NATURAL JOIN t_nfl_players WHERE week_id=$weekId'

dbase = db.database(dbn='mysql', db='AuctionBeta', user='******')


def query(queryString, queryParams):
    return dbase.query(queryString, vars=queryParams)


def register(username, password, email):
    password = sha256_crypt.encrypt(password)
    query(INSERT_NEW_USER, {
        'username': username,
        'password': password,
        'email': email
    })
    return True
コード例 #5
0
def get_db(coop):
    return database(dbn='postgres',
                    user=coop.config['Database']['USERNAME'],
                    pw=coop.config['Database']['PASSWORD'],
                    db='coop')