*controlelrs/test.py*
from peewee import *
db = SqliteDatabase('peewee.sqlite')
class BaseModel(Model):
class Meta:
database = db
class Person(BaseModel):
name = CharField()
def peewee_create_tables():
with db:
db.create_tables([Person] )
def peewee_get():
table_name = request.args(0)
peewee_create_tables()
all_columns = Person.select()
all_columns_output = [e for e in all_columns.tuples() ]
return str(all_columns_output)
*objective*
can pass the table name from curl terminal cli into request.args(0)
*e.g.*
all_columns = table_name.select()
*result*
Traceback (most recent call last):
File "/Users/sugizo/Downloads/web2py/gluon/restricted.py", line 219, in
restricted
exec(ccode, environment)
File
"/Users/sugizo/Downloads/web2py/applications/test/controllers/test.py",
line 95, in <module>
File "/Users/sugizo/Downloads/web2py/gluon/globals.py", line 430, in
<lambda>
self._caller = lambda f: f()
File
"/Users/sugizo/Downloads/web2py/applications/test/controllers/test.py",
line 47, in peewee_get
all_columns = table_name.select()
AttributeError: 'str' object has no attribute 'select'
*question*
how to pass the request.args(0) into class <class 'peewee.ModelBase'> 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/bfeb0f1d-3fd0-42a5-8907-479fe14537ben%40googlegroups.com.