python/pythontest/db/SimpleConnection.py

16 lines
376 B
Python
Raw Permalink Normal View History

2020-10-13 00:55:40 +02:00
from pythontest.DatabaseConnection import DatabaseConnection
class SimpleConnection(DatabaseConnection):
def __init__(self, config):
self.user = config['user']
def query(self, stmt: str):
typ, ids = stmt.split(':', 1)
ids = ids.split(',')
name = '%s %s for %s'
result = [ { 'id': int(id), 'name': name % (typ, id, self.user) } for id in ids ]
return result