[storm] Maturity
Jamu Kakar
jkakar at kakar.ca
Tue Aug 17 22:22:23 BST 2010
Hi Craig,
On Tue, Aug 17, 2010 at 2:11 PM, Craig <craig at hivemind.net> wrote:
> How mature is storm? I use SQL Alchemy from time to time, and thought
> I'd take a look at storm. The very first thing I tried was to list the
> contents of a table, which happened to have a date column.
Storm is used by several Canonical projects, in production,
including Landscape and Launchpad. I know there are several users
on this list that are using it on other projects, in live production
environments. It's stable.
> So - how does a person convert a DateTime into a readable string? I
> cannot even find a list of valid attributes of the DateTime class. Is
> there one?
Have you read the tutorial [1]? It should give you a good
high-level overview of Storm. But anyway, hopefully this will
answer you question (untested):
from datetime import datetime, timedelta
from storm.locals import DateTime, Int, Store, create_database
class Person(object):
__storm_table__ = "person"
id = Int(primary=True)
birthdate = DateTime()
def __init__(self, birthdate):
self.birthdate = birthdate
You can connect to a database and run statements like:
database = create_database("sqlite:") # In-memory SQLite
store = Store(database)
store.execute("CREATE TABLE person (...)")
You can create objects and add them to the database:
store.add(Person(datetime.utcnow()))
store.add(Person(datetime.utcnow() - timedelta(days=1)))
You can fetch objects from the database and use them as you normally
would:
result = store.find(Person)
result.order_by(Person.birthdate)
for person in result:
# person.birthdate is a normal Python datetime object
print person.birthdate.strftime("%Y-%m-%d")
I hope this helps.
Thanks,
J.
[1] https://storm.canonical.com/Tutorial
More information about the storm
mailing list