Ejemplo n.º 1
0
 def _benchmark_set_up(self):
     self.citizen = city.Citizen(name="Lukas", age=93)
     self.city = city.City(name="Freiburg", coordinates=[108, 49])
     self.address = city.Address(postalCode=79111)
     self.things = itertools.cycle((self.citizen, self.city, self.address))
     self.attributes = itertools.cycle(
         (("age",), ("coordinates",), ("postalCode",))
     )
    p = subprocess.Popen(args)
except FileNotFoundError:
    args[0] = "python"
    p = subprocess.Popen(args)
time.sleep(5)

try:
    # Construct the Datastructure.
    c = city.City(name="Freiburg")
    p1 = city.Citizen(name="Peter")
    p2 = city.Citizen(name="Hans")
    p3 = city.Citizen(name="Michel")
    n = city.Neighborhood(name="Zähringen")
    s = city.Street(name="Le street")
    b = city.Building(name="Theater")
    a = city.Address(postalCode=79123, name='Le street', number=12)
    c.add(p1, p2, p3, rel=city.hasInhabitant)
    c.add(n).add(s).add(b).add(a)

    print("Connect to DB via transport session")
    with TransportSessionClient(
        SqliteSession, "ws://localhost:8688", path="test.db"
    ) as session:
        wrapper = city.CityWrapper(session=session)
        wrapper.add(c)
        wrapper.session.commit()

    print("Reconnect and check if data is still there")
    with TransportSessionClient(
        SqliteSession, "ws://localhost:8688", path="test.db"
    ) as session: