Thanks Anthony, that's exactly right. In fact, there is even no need
for us to call db.define_table('person') at all with RedBean. It would
look more like dal.insert(<tablename>, <name>=<value>, ...) and
<tablename> gets created automatically if it does not exist.

The best use case IMO is the ability to store/insert variable
dictionaries like request.vars, say, when you want to have some
general debugging/monitoring for different controllers.

Looking at some of the examples from Massimo, it seems that it might
not be too difficult to implement the association manager with some
extra functions, as well as extending the db.<table>.insert() function
to support on-the-fly schema extensions. (Of course I'm saying this
from a very high level POV; I don't know how much work it would
actually take.)

On Jan 30, 11:13 pm, Anthony <abasta...@gmail.com> wrote:
> On Monday, January 30, 2012 9:37:29 AM UTC-5, Massimo Di Pierro wrote:
>
> > You can create schemas on the fly with web2py (web2py will do the
> > alter table).
>
> I think in RedBean you don't have to define the schema at all. With the
> DAL, it would look something like:
>
> db.define_table('person')
> db.person.insert(name='John')
>
> Notice that the 'name' field was never defined before the insert -- the
> insert prompts the creation of the 'name' column in the 'person' table
> (type is inferred based on the data, and altered if necessary based on
> subsequent inserts). So, it enables use of a schema-based RDBMS more like a
> schema-less NoSQL db. This "fluid" mode is recommended in development only,
> after which, you are advised to "freeze" the
> schema:http://redbeanphp.com/manual/freeze. So, it's taking automatic
> migrations a step further and doing automatic (inferred) schema definitions
> as well.
>
> Anthony

Reply via email to