In storm, I miss the feature to have an automatic generated schema.
For example: I must write
1 from storm.locals import *
2
3 store = Store(create_database('sqlite:'))
4
5 class Movie(object):
6 __storm_table__ = 'movies'
7 id = Int(primary=True)
8 title = Char()
9 language = Char()
10 length_in_min = Int()
11 description = Unicode()
12
13 store.execute('CREATE TABLE movies '
14 '(id INTEGER PRIMARY KEY, title VARCHAR, language VARCHAR, length_in_min INTEGER,'
15 'description TEXT)')
I think the last part (store.execute(...)) is unnecessary. You can set default values for the SQL part and if you want to change something, you can change it via argument:
Also, now is title a Text field and you needn't to write the last part for changing it. I think it's better because mostly, the first part is the same like the second part. And with this solution it's simpler to write your own store and define you own database in an other file than the database model. Example:
1 # database.py
2
3 store = Store(create_database('sqlite:'))
4
5 class Movie(object):
6 __storm_table__ = 'movies'
7 id = Int(primary=True)
8 title = Char()
9 language = Char()
10 length_in_min = Int()
11 description = Unicode()
12
13 store.execute('CREATE TABLE movies '
14 '(id INTEGER PRIMARY KEY, title VARCHAR, language VARCHAR, length_in_min INTEGER,'
15 'description TEXT)')
16
17 # application.py
18
19 from database import store, Movie
With my idea you can make
1 # database.py
2
3 store = Store(create_database('sqlite:')
4
5 class Movie(object):
6 __storm_table__ = 'movies'
7 id = Int(primary=True)
8 title = Char()
9 language = Char()
10 length_in_min = Int()
11 description = Unicode()
12
13 # application.py
14
15 from storm.locals import *
16
17 from database import Movie
18
19 store = Store(create_database('sqlite:')
20 store.add_table(Movie)
21
22 # do inserts, selects and other stuff...
But maybe this is another idea.
And for people who don't like that, you can put in an own file that you must import it extra.
So that you can work with it or without it.
Just an idea...
Cheers,
Rafael Weber