You can create schemas on the fly with web2py (web2py will do the
alter table). It would be possible to allow redefining a table within
the same http request but why?

you can also do this:

def associate(t1, t2, *fields):
     db = t1._db
     f1 = t1._tablename+'_id'
     f2 = t2._tablename+'_id'
     name = t1._tablename+'_'+t2._tablename
     t3 = db.define_table(name,Field(f1,t1),Field(f2,t2),*fields)
     return (t3[f1]==t1.id)&(t3[f2]==t2.id)
def link(association,rec1,rec2):
     table = association.first.first.table
     f1,f2 = table.fields[1:3]
     return table.insert(**{f1:rec1.id,f2:rec2.id})

db.define_table('person',Field('name'))
db.define_table('dog',Field('name'))

john = db.person.insert(name = 'John')
snoopy = db.dog.insert(name = 'Snoopy')

ownership = associate(db.person,db.dog)
link(ownership, john, snoopy)

rows = db(ownership).select(db.person.name,db.dog.name)


On Jan 30, 3:15 am, Chnrxn <chn...@gmail.com> wrote:
> It brings in the power of NoSQL. On my part, having used SQLObject,
> SQLAlchemy, DAL, and RedBean, I find that Redbean does a wonderful job
> of removing obstacles, no doubt many might deem them to be
> insignificant, during development. It does make a big difference for
> me, especially during development phase when the schema design changes
> frequently.
>
> In a sentence, this is the ability to create/adjust schemas on-the-
> fly. (#1)
>
> The other major advantage is that RedBean makes associating objects in
> different tables a no-brainer without having to deal with foreign keys
> explicitly, i.e. an Association Manager (#2)
>
> http://redbeanphp.com/community/wiki/index.php/Associationshttp://redbeanphp.com/community/wiki/index.php/Advanced_Associations
>
> You just have to try it to appreciate it.
>
> #1 and #2 would be the top 2 features I would be thrilled to use in
> Web2py.
>
> Cheers!
>
> On Jan 28, 6:46 am, pbreit <pbreitenb...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Is the main benefit not having to pre-define models? I suppose that could
> > be nice during development but don't find that to be a big problem with DAL.
>
> > DAL is pretty integral to Web2py and one of the most popular features. And
> > it has many of the same advantages as RedBean and from my brief look,
> > appears much easier to understand. It's hard to see how something like
> > RedBean would be incorporated. I suppose there's nothing stopping one from
> > trying to create some sort of module or add-on.

Reply via email to