diff options
author | Random Hacker <random_hacker@xapek.org> | 2010-08-29 00:14:18 +0200 |
---|---|---|
committer | Random Hacker <random_hacker@xapek.org> | 2010-08-29 00:14:18 +0200 |
commit | 8c78916ff0dcf7d10b6f599e07c8bc345263ea56 (patch) | |
tree | 3ba85b577b5fa131785c7d0222b42ed70687e5d0 | |
parent | a700fe3774b5a9e37a7214bcfcc1ea1d155f6769 (diff) | |
download | ebus-alt-8c78916ff0dcf7d10b6f599e07c8bc345263ea56.tar.gz ebus-alt-8c78916ff0dcf7d10b6f599e07c8bc345263ea56.zip |
add orm test skript
-rwxr-xr-x | ormtest.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ormtest.py b/ormtest.py new file mode 100755 index 0000000..91b8277 --- /dev/null +++ b/ormtest.py @@ -0,0 +1,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() + |