voltron
unread,Jan 15, 2008, 9:22:49 AM1/15/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py Web Framework
I am having problems migrating a PostgreSQL database
This is how I have declared my database in the model.py file:
db=SQLDB("postgres://voltron:test@localhost:5432/test_db")
db.define_table('users',
SQLField('group_type' , 'string', length=50),
SQLField('user_name' , 'string', length=50),
SQLField('password' , 'string', length=50),
SQLField('email' , 'string', length=50),
SQLField('is_active' , 'boolean', default=True),
SQLField('has_profile' , 'boolean', default=False),
#SQLField('passwordfield', 'password'),
#SQLField('textfield' , 'text'),
SQLField('created_on' , 'date',
default=datetime.date.today()),
SQLField('modified_on', 'datetime'),
#SQLField('timefield' , 'time'),
migrate = False
)
This is how the database was declared using SQLAlchemy:
users = Table("users", metadata,
Column("id", Integer, primary_key = True),
Column("group_type", String(50)),
Column("user_name", String(50), unique = True, nullable =
False),
Column("password", String(50)),
Column("email", String(50)),
Column("is_active", Boolean, default = True),
Column("has_profile", Boolean, default = False),
Column("created_on", DateTime(),
default=datetime.datetime.now()),
Column("modified_on", DateTime(),
onupdate=datetime.datetime.now())
)
I can create an SQLForm from the table definition but I cannot display
the data in the table using SQLTable. I receive this traceback:
1. Traceback (most recent call last):
2. File "D:\projects\website\web2py\gluon\restricted.py", line
65, in restricted
3. exec ccode in environment
4. File "applications/main/controllers/default.py", line 7, in
<module>
5. File "applications/main/controllers/default.py", line 4, in
index
6. records=SQLTABLE(db().select(db.users.ALL))
7. File "D:\projects\website\web2py\gluon\sqlhtml.py", line 218,
in __init__
8. r=str(field.formatter(r))
9. File "D:\projects\website\web2py\gluon\sql.py", line 593, in
formatter
10. if hasattr(item,'formatter'): value=item.formatter(value)
11. File "D:\projects\website\web2py\gluon\validators.py", line
270, in formatter
12. return value.strftime(self.format)
13. AttributeError: 'NoneType' object has no attribute 'strftime'
Any ideas?
Thanks