def get_ssys(conn, name): '''Get the named star system from an open database.''' ssys = SSystem() ssys.name = name cur = conn.cursor() # Get the basic system data. cur.execute('''SELECT SSysID, SSysPosX, SSysPosY, SSysRadius, SSysStars , SSysInterference, SSysNebulaDensity, SSysNebulaVolatility FROM SSystems WHERE SSysName = ?''', (name,)) row = cur.fetchone() if row is None: # Nothing but a name! return ssys else: ssys_id = row['SSysID'] ssys.pos.x, ssys.pos.y = row['SSysPosX'], row['SSysPosY'] ssys.radius, ssys.stars = row['SSysRadius'], row['SSysStars'] ssys.interference = row['SSysInterference'] ssys.nebula.density = row['SSysNebulaDensity'] ssys.nebula.volatility = row['SSysNebulaDensity'] _get_ssys_extras(conn, ssys, ssys_id) return ssys
def get_ssystems(conn): '''Get all star systems from an open database.''' ssystems = [] cur = conn.cursor() cur.execute('''SELECT SSysID, SSysPosX, SSysPosY, SSysRadius, SSysStars , SSysInterference, SSysNebulaDensity, SSysNebulaVolatility FROM SSystems''') for row in cur: ssys = SSystem() ssys.pos.x, ssys.pos.y = row['SSysPosX'], row['SSysPosY'] ssys.radius, ssys.stars = row['SSysRadius'], row['SSysStars'] ssys.interference = row['SSysInterference'] ssys.nebula.density = row['SSysNebulaDensity'] ssys.nebula.volatility = row['SSysNebulaDensity'] ssys_id = row['SSysID'] _get_ssys_extras(conn, ssys, ssys_id) ssystems.append(ssys) return ssystems