*modules/database_pydal*
def database():
from pydal import DAL
DB_URI = "sqlite://test.sqlite"
db = DAL(DB_URI, pool_size = 1, migrate = True,
fake_migrate = False)
return db
def table_customer():
from pydal import Field
from pydal.validators import IS_NOT_EMPTY
db = database()
db.define_table('customer',
Field('name', requires = IS_NOT_EMPTY() ),
Field('address', requires = IS_NOT_EMPTY() )
)
db.customer._enable_record_versioning()
return db
def table_sales():
from pydal import Field
from pydal.validators import IS_NOT_EMPTY
db = database()
db.define_table('sales',
Field('sales_date', requires = IS_NOT_EMPTY() ),
Field('sales_no', requires = IS_NOT_EMPTY() )
)
db.sales._enable_record_versioning()
return db
def tables_sales():
db = database()
db = table_customer()
db = table_sales()
return db
*controllers/default.py*
def tables_sales():
from database_pydal import tables_sales
query = (db['customer']['id'] > 0)
rows = db(query).select().as_json()
return rows
*objective*
modules tables_sales can load both table customer and table sales (similar
to response.models_to_run)
*question*
how can achieve it using web2py way ?
thanks and best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/ec242f01-dee7-49d0-9447-070d83f97574n%40googlegroups.com.