yeah , i lost all my data everytime i change a datatype for afield , in the
table defination..

So , how to make it work without dropping?



On Fri, Oct 10, 2008 at 6:00 PM, mdipierro <[EMAIL PROTECTED]> wrote:

>
> No. In principle you should never drop. When you drop you lose all
> your data.
>
>
> On Oct 10, 12:50 pm, "Phyo Arkar" <[EMAIL PROTECTED]> wrote:
> > Thanks I will try;
> >
> > if i alter table , have to always drop?
> >
> > On Fri, Oct 10, 2008 at 5:40 PM, mdipierro <[EMAIL PROTECTED]>
> wrote:
> >
> > > You can only drop it after define.
> >
> > > If you know for sure the table exists it is ok to do
> >
> > > db=SQLDB(..)
> > > db.define_table('student',migrate=False)
> > > db.student.drop()
> >
> > > On Oct 10, 12:22 pm, "Phyo Arkar" <[EMAIL PROTECTED]> wrote:
> > > > Code :
> >
> > > > dbOBJECT.define_table("student",
> > > >       SQLField("std_id", "string", length=32, notnull=True,
> > > default=None),
> > > >       SQLField("std_name", "string", length=80, notnull=True,
> > > default=None),
> > > >       SQLField("password", "password", notnull=True, default=None))
> >
> > > > On Fri, Oct 10, 2008 at 5:21 PM, Phyo Arkar <
> [EMAIL PROTECTED]
> > > >wrote:
> >
> > > > > Another DB problem
> >
> > > > > I tried to changed database schema , data type Text to string , and
> now
> > > it
> > > > > is giving this error :
> >
> > > > > code :
> >
> > > > > Ticket
> > > 127.0.0.1.2008-10-10.23-35-33.c7c54895-a27b-43b1-bf3d-2888acd4527e
> >
> > > > > Error traceback
> >
> > > > > 1.
> > > > > 2.
> > > > > 3.
> > > > > 4.
> > > > > 5.
> > > > > 6.
> > > > > 7.
> > > > > 8.
> > > > > 9.
> >
> > > > > Traceback (most recent call last
> > > > > ):
> > > > >   File "/opt/web2py/gluon/main.py", line 231, in wsgibase
> >
> > > > >     SQLDB.close_all_instances(SQLDB.rollback)
> >
> > > > >   File "/opt/web2py/gluon/sql.py", line 299, in close_all_instances
> >
> > > > >     action(instance)
> > > > >   File "/opt/web2py/gluon/sql.py", line 509, in rollback
> >
> > > > >     self._connection.rollback()
> > > > > ProgrammingError: (2014, "Commands out of sync; you can't run this
> > > command now")
> >
> > > > > Powered by web2py <http://www.web2py.com/> (TM) created by Massimo
> Di
> > > > > Pierro (c) 2007, 2008
> >
> > > > > SO i tried to drop but without success :
> >
> > > > > In [3]: dbOBJECT = SQLDB("mysql://[EMAIL PROTECTED]/ealba")
> >
> > > > > In [4]: dbOBJECT.student.drop()
> >
> > >
> ---------------------------------------------------------------------------
> > > > > KeyError                                  Traceback (most recent
> call
> > > last)
> >
> > > > > /opt/web2py/<ipython console> in <module>()
> >
> > > > > /opt/web2py/gluon/sql.pyc in __getattr__(self, key)
> > > > >     248     a dictionary that let you do d['a'] as well as d.a
> > > > >     249     """
> > > > > --> 250     def __getattr__(self, key): return self[key]
> > > > >     251     def __setattr__(self, key, value):
> > > > >     252         if self.has_key(key):
> >
> > > > > KeyError: 'student'
> >
> > > > > Models cannot be load as there is error.
> >
> > > > > On Tue, Sep 30, 2008 at 2:20 AM, mdipierro <
> [EMAIL PROTECTED]
> > > >wrote:
> >
> > > > >> I think it would be too dangerous.
> >
> > > > >> python web2py.py -S myapp
> > > > >> >>> db.table.drop()
> >
> > > > >> seems easy enough.
> >
> > > > >> On Sep 29, 8:18 pm, yarko <[EMAIL PROTECTED]> wrote:
> > > > >> > I wounder if it would be worthwhile to add "drop table" to the
> db
> > > > >> > administration gui at some point?
> >
> > > > >> > On Sep 29, 4:43 pm, "Phyo Arkar" <[EMAIL PROTECTED]>
> wrote:
> >
> > > > >> > > Dear Massimo;
> >
> > > > >> > > I deleted via Mysql console..
> >
> > > > >> > > Thats why i think it messedup..
> >
> > > > >> > > Now it ok after i deleted everything under database folder.
> >
> > > > >> > > Thanks a lot.
> >
> > > > >> > > On 9/29/08, mdipierro <[EMAIL PROTECTED]> wrote:
> >
> > > > >> > > > What do you mean by "after I deleted the table"?
> >
> > > > >> > > > You are supposed to use web2py command
> >
> > > > >> > > > python web2py.py -S youapp -M
> > > > >> > > > >>> albereport.report.drop().
> > > > >> > > > >>> albereport.commit()
> >
> > > > >> > > > If you want to delete a table manually there are two things
> you
> > > need
> > > > >> > > > to do:
> > > > >> > > > 1) DROP TABLE using SQL
> > > > >> > > > 2) delete the corresponding app/databases/***.table
> >
> > > > >> > > > If you did 1 without 2 or vice versa you need to complete
> the
> > > > >> > > > complementary op for it to succeed. If you are suing sqlite,
> it
> > > will
> > > > >> > > > be clearer to just remove everything in databases/*
> (assuming no
> > > > >> > > > valuable data in there).
> >
> > > > >> > > > Massimo
> >
> > > > >> > > > On Sep 29, 2:52 pm, "Phyo Arkar" <[EMAIL PROTECTED]>
> > > wrote:
> > > > >> > > > > Dear All..
> >
> > > > >> > > > > Suddenly Web2py stop working , it happen after i deleted
> the
> > > > >> table.. But
> > > > >> > > > it
> > > > >> > > > > do not recreate..
> >
> > > > >> > > > > Code is as below
> >
> > > > >> > > > > from gluon.sql import *
> > > > >> > > > > #import gluon.validators as vd
> > > > >> > > > > albareport=SQLDB("mysql://[EMAIL PROTECTED]/studentreport")
> >
> > >
> albareport.define_table('student',SQLField('std_id'),SQLField('username','t
> > > > >> ext'),SQLField('password','password'))
> >
> > > > >> > > > > albareport.define_table('report'
> >
> > >
> ,SQLField('result_date'),SQLField('std_id',albareport.student),SQLField('ma
> > > > >> rk'))
> >
> > > > >> > > > > msg="null"
> >
> > >
> albareport.student.std_id.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(albareport,
> > > > >> 'student.std_id')]
> > > > >> > > > > albareport.student.username.requires=[IS_NOT_EMPTY()]
> >
> > > > >> > > > > albareport.report.std_id.requires=IS_IN_DB(albareport,
> > > > >> > > > albareport.student.id
> > > > >> > > > > ,albareport.student.std_id)
> > > > >> > > > > albareport.report.mark.requires=IS_NOT_EMPTY()
> > > > >> > > > > Error traceback
> >
> > > > >> > > > > 1.
> > > > >> > > > > 2.
> > > > >> > > > > 3.
> > > > >> > > > > 4.
> > > > >> > > > > 5.
> > > > >> > > > > 6.
> > > > >> > > > > 7.
> >
> > > > >> > > > > Traceback (most recent call last):
> > > > >> > > > >   File "/root/web2py/web2py/gluon/restricted.py", line 62,
> in
> > > > >> restricted
> > > > >> > > > >   File
> > > > >> "/opt/web2py/applications/albastudent/models/albareport.py",
> > > > >> > > > > line 8, in <module>
> > > > >> > > > >     albareport.define_table('report'
> >
> > >
> ,SQLField('result_date'),SQLField('std_id',albareport.student),SQLField('ma
> > > > >> rk'))
> > > > >> > > > >   File "/root/web2py/web2py/gluon/sql.py", line 500, in
> > > > >> define_table
> > > > >> > > > > ProgrammingError: (1146, "Table 'studentreport.report'
> doesn't
> > > > >> exist")
> >
> > > > >> > > > > Why? Web2py suppose to recreate the Table if it is not
> > > existed..
> > > > >> whats
> > > > >> > > > > wrong.. i cannot fix my app anyway ..
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to