5. Crate
all common SQL types(and more)
powerful aggregations (‘GROUP BY’)
linear scalability - data and query execution is
distributed
basic arithmetics (next release 0.39)
14. Using SQLAlchemy
>>> import sqlalchemy as sa
>>> from sqlalchemy.ext.declarative import
declarative_base
>>> from sqlalchemy.orm import sessionmaker
>>> engine = sa.create_engine(“crate://localhost:4200”)
>>> Base = declarative_base()
16. Using SQLAlchemy
>>> from sa import func
>>> res = DBSession.query(
... Weather.station_name,
... func.avg(Weather.temp)
... ).group_by(Weather.station_name)
... .order_by(Weather.station_name)
... .limit(10).all()
SELECT station_name, avg(temp) from weather group by station_name
order by station_name limit 10;
17. Using SQLAlchemy
#Average sunshine hours
from sqlalchemy.sql import func
DBSession.query(func.avg(Weather.sunshine_hours)).scalar()
# Average sunshine hours in Konstanz
DBSession.query(func.avg(Weather.sunshine_hours)).filter(Weather.station_name==
‘Konstanz’).scalar()