How to use the littletable.Table function in littletable

To help you get started, we’ve selected a few littletable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jhakonen / wot-teamspeak-mod / tessumod / src / scripts / client / gui / mods / tessumod / database.py View on Github external
from collections import Mapping

from littletable import Table, DataObject
import pydash as _

import os

messages = None

logger = logutils.logger.getChild('database')

_me_player = Table('me_player')
_me_player.create_index('id', unique=True)
_battle_players = Table('battle_players')
_battle_players.create_index('id', unique=True)
_vehicles = Table('vehicles')
_vehicles.create_index('id', unique=True)
_vehicles.create_index('player_id', unique=True)
_prebattle_players = Table('prebattle_players')
_prebattle_players.create_index('id', unique=True)
_speaking_players = Table('speaking_players')
_speaking_players.create_index('id', unique=True)
_users = Table('users')
_users.create_index('id', unique=True)
_users.create_index('unique_id')
_cached_users = Table('cached_users')
_cached_users.create_index('unique_id', unique=True)
_cached_players = Table('cached_players')
_cached_players.create_index('id', unique=True)
_pairings = Table('pairings')
_pairings.create_index('player_id')
_pairings.create_index('user_unique_id')
github jhakonen / wot-teamspeak-mod / tessumod / src / scripts / client / gui / mods / tessumod / migrate.py View on Github external
players_filepath  = os.path.join(dest_dirpath, constants.PLAYERS_CACHE_FILE)
	pairings_filepath = os.path.join(dest_dirpath, constants.PAIRINGS_CACHE_FILE)
	backup_filepath   = os.path.join(dest_dirpath, "tessu_mod_cache.ini.old-0.6")

	source_exists = os.path.isfile(source_filepath)
	dest_exists = all(map(os.path.isfile, [users_filepath, players_filepath, pairings_filepath]))

	if source_exists and not dest_exists:
		logger.info("Migrating caches from version 0.6 to 0.7")

		# Schema for new caches
		users = Table()
		users.create_index('unique_id', unique=True)
		players = Table()
		players.create_index('id', unique=True)
		pairings = Table()
		pairings.create_index('player_id')
		pairings.create_index('user_unique_id')

		# Load old 0.6.x cache file
		parser = ConfigParser.ConfigParser()
		with open(source_filepath, "rb") as file:
			parser.readfp(file)

		# Build new cache structures
		users.insert_many(DataObject(unique_id=id, name=name) for name, id in parser.items("TeamSpeakUsers"))
		players.insert_many(DataObject(id=int(id), name=name) for name, id in parser.items("GamePlayers"))
		for user_name, player_names in parser.items("UserPlayerPairings"):
			userid = _.head(users.where(name=user_name)).unique_id
			for player_name in list(csv.reader([player_names]))[0]:
				playerid = _.head(players.where(name=player_name)).id
				pairings.insert(DataObject(player_id=int(playerid), user_unique_id=userid))
github jhakonen / wot-teamspeak-mod / tessumod / src / scripts / client / gui / mods / tessumod / migrate.py View on Github external
* pairings_cache.v1.json
	"""
	source_filepath   = os.path.join(source_dirpath, "tessu_mod_cache.ini")
	users_filepath    = os.path.join(dest_dirpath, constants.USERS_CACHE_FILE)
	players_filepath  = os.path.join(dest_dirpath, constants.PLAYERS_CACHE_FILE)
	pairings_filepath = os.path.join(dest_dirpath, constants.PAIRINGS_CACHE_FILE)
	backup_filepath   = os.path.join(dest_dirpath, "tessu_mod_cache.ini.old-0.6")

	source_exists = os.path.isfile(source_filepath)
	dest_exists = all(map(os.path.isfile, [users_filepath, players_filepath, pairings_filepath]))

	if source_exists and not dest_exists:
		logger.info("Migrating caches from version 0.6 to 0.7")

		# Schema for new caches
		users = Table()
		users.create_index('unique_id', unique=True)
		players = Table()
		players.create_index('id', unique=True)
		pairings = Table()
		pairings.create_index('player_id')
		pairings.create_index('user_unique_id')

		# Load old 0.6.x cache file
		parser = ConfigParser.ConfigParser()
		with open(source_filepath, "rb") as file:
			parser.readfp(file)

		# Build new cache structures
		users.insert_many(DataObject(unique_id=id, name=name) for name, id in parser.items("TeamSpeakUsers"))
		players.insert_many(DataObject(id=int(id), name=name) for name, id in parser.items("GamePlayers"))
		for user_name, player_names in parser.items("UserPlayerPairings"):
github jhakonen / wot-teamspeak-mod / tessumod / src / scripts / client / gui / mods / tessumod / database.py View on Github external
_battle_players.create_index('id', unique=True)
_vehicles = Table('vehicles')
_vehicles.create_index('id', unique=True)
_vehicles.create_index('player_id', unique=True)
_prebattle_players = Table('prebattle_players')
_prebattle_players.create_index('id', unique=True)
_speaking_players = Table('speaking_players')
_speaking_players.create_index('id', unique=True)
_users = Table('users')
_users.create_index('id', unique=True)
_users.create_index('unique_id')
_cached_users = Table('cached_users')
_cached_users.create_index('unique_id', unique=True)
_cached_players = Table('cached_players')
_cached_players.create_index('id', unique=True)
_pairings = Table('pairings')
_pairings.create_index('player_id')
_pairings.create_index('user_unique_id')

def import_caches(users_file, players_file, pairings_file):
	"""
	Loads user, player and pairing caches from files.

	May raise an error, if importing fails.

	:param users_file:    users cache file (file object or path to file)
	:param players_file:  players cache file (file object or path to file)
	:param pairings_file: pairings cache file (file object or path to file)
	"""
	global _cached_users, _cached_players, _pairings
	logger.debug('Importing caches')
	users    = _cached_users.copy_template()
github jhakonen / wot-teamspeak-mod / tessumod / src / scripts / client / gui / mods / tessumod / migrate.py View on Github external
source_filepath   = os.path.join(source_dirpath, "tessu_mod_cache.ini")
	users_filepath    = os.path.join(dest_dirpath, constants.USERS_CACHE_FILE)
	players_filepath  = os.path.join(dest_dirpath, constants.PLAYERS_CACHE_FILE)
	pairings_filepath = os.path.join(dest_dirpath, constants.PAIRINGS_CACHE_FILE)
	backup_filepath   = os.path.join(dest_dirpath, "tessu_mod_cache.ini.old-0.6")

	source_exists = os.path.isfile(source_filepath)
	dest_exists = all(map(os.path.isfile, [users_filepath, players_filepath, pairings_filepath]))

	if source_exists and not dest_exists:
		logger.info("Migrating caches from version 0.6 to 0.7")

		# Schema for new caches
		users = Table()
		users.create_index('unique_id', unique=True)
		players = Table()
		players.create_index('id', unique=True)
		pairings = Table()
		pairings.create_index('player_id')
		pairings.create_index('user_unique_id')

		# Load old 0.6.x cache file
		parser = ConfigParser.ConfigParser()
		with open(source_filepath, "rb") as file:
			parser.readfp(file)

		# Build new cache structures
		users.insert_many(DataObject(unique_id=id, name=name) for name, id in parser.items("TeamSpeakUsers"))
		players.insert_many(DataObject(id=int(id), name=name) for name, id in parser.items("GamePlayers"))
		for user_name, player_names in parser.items("UserPlayerPairings"):
			userid = _.head(users.where(name=user_name)).unique_id
			for player_name in list(csv.reader([player_names]))[0]:
github jhakonen / wot-teamspeak-mod / tessumod / src / scripts / client / gui / mods / tessumod / database.py View on Github external
_me_player = Table('me_player')
_me_player.create_index('id', unique=True)
_battle_players = Table('battle_players')
_battle_players.create_index('id', unique=True)
_vehicles = Table('vehicles')
_vehicles.create_index('id', unique=True)
_vehicles.create_index('player_id', unique=True)
_prebattle_players = Table('prebattle_players')
_prebattle_players.create_index('id', unique=True)
_speaking_players = Table('speaking_players')
_speaking_players.create_index('id', unique=True)
_users = Table('users')
_users.create_index('id', unique=True)
_users.create_index('unique_id')
_cached_users = Table('cached_users')
_cached_users.create_index('unique_id', unique=True)
_cached_players = Table('cached_players')
_cached_players.create_index('id', unique=True)
_pairings = Table('pairings')
_pairings.create_index('player_id')
_pairings.create_index('user_unique_id')

def import_caches(users_file, players_file, pairings_file):
	"""
	Loads user, player and pairing caches from files.

	May raise an error, if importing fails.

	:param users_file:    users cache file (file object or path to file)
	:param players_file:  players cache file (file object or path to file)
	:param pairings_file: pairings cache file (file object or path to file)
github jhakonen / wot-teamspeak-mod / tessumod / src / scripts / client / gui / mods / tessumod / database.py View on Github external
import os

messages = None

logger = logutils.logger.getChild('database')

_me_player = Table('me_player')
_me_player.create_index('id', unique=True)
_battle_players = Table('battle_players')
_battle_players.create_index('id', unique=True)
_vehicles = Table('vehicles')
_vehicles.create_index('id', unique=True)
_vehicles.create_index('player_id', unique=True)
_prebattle_players = Table('prebattle_players')
_prebattle_players.create_index('id', unique=True)
_speaking_players = Table('speaking_players')
_speaking_players.create_index('id', unique=True)
_users = Table('users')
_users.create_index('id', unique=True)
_users.create_index('unique_id')
_cached_users = Table('cached_users')
_cached_users.create_index('unique_id', unique=True)
_cached_players = Table('cached_players')
_cached_players.create_index('id', unique=True)
_pairings = Table('pairings')
_pairings.create_index('player_id')
_pairings.create_index('user_unique_id')

def import_caches(users_file, players_file, pairings_file):
	"""
	Loads user, player and pairing caches from files.
github jhakonen / wot-teamspeak-mod / tessumod / src / scripts / client / gui / mods / tessumod / database.py View on Github external
import pydash as _

import os

messages = None

logger = logutils.logger.getChild('database')

_me_player = Table('me_player')
_me_player.create_index('id', unique=True)
_battle_players = Table('battle_players')
_battle_players.create_index('id', unique=True)
_vehicles = Table('vehicles')
_vehicles.create_index('id', unique=True)
_vehicles.create_index('player_id', unique=True)
_prebattle_players = Table('prebattle_players')
_prebattle_players.create_index('id', unique=True)
_speaking_players = Table('speaking_players')
_speaking_players.create_index('id', unique=True)
_users = Table('users')
_users.create_index('id', unique=True)
_users.create_index('unique_id')
_cached_users = Table('cached_users')
_cached_users.create_index('unique_id', unique=True)
_cached_players = Table('cached_players')
_cached_players.create_index('id', unique=True)
_pairings = Table('pairings')
_pairings.create_index('player_id')
_pairings.create_index('user_unique_id')

def import_caches(users_file, players_file, pairings_file):
	"""

littletable

Python in-memory ORM database

MIT
Latest version published 2 months ago

Package Health Score

66 / 100
Full package analysis

Popular littletable functions

Similar packages