summaryrefslogtreecommitdiff
path: root/ormtest.py
blob: 91b8277f3b0f362e8293b88be05a401303d987c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python
from ebus.web import model
from sqlalchemy import create_engine

#engine = create_engine('sqlite:///:memory:', echo=True)
engine = create_engine("postgresql:///ebus_test", echo=False)

model.ModelBase.metadata.create_all(engine)

from sqlalchemy.orm import sessionmaker
Session = sessionmaker()
Session.configure(bind=engine)

session = Session()

t1_sensor = model.Sensor("foosensor", "blatest")
session.add(t1_sensor)

#annahme 100  mal 3 values /min
for i in xrange(360*24*60*100):
    session.add( model.ValueInt(t1_sensor, 1) )

    session.add( model.ValueFloat(t1_sensor, 1.2) )

    session.add( model.ValueString(t1_sensor, "foobar") )

    if i%1000 == 0:
        print i
        session.commit()

session.commit()
session.close()