This works for me:
$ python web2py.py -S welcome -N
>>> db = DAL()
>>> db.define_table('tablename',Field('name'))
<Table tablename (id,name)>
>>> db.tablename.drop()
Are you try to drop a table "tablename" that was not defined?
On Sunday, 30 September 2012 11:55:09 UTC-5, curiouslearn wrote:
>
> Recently I created a simple game in web2py for educational purposes. It
> worked out well, however, for this game I did not make use of a lot of
> functionality available in web2py; especially the DAL. I used MySQLdb and
> raw sql queries to do the job. Based on the recommendations here, I have
> decided to use web2py DAL and other tools provided by web2py to rewrite
> the game and to create other apps using web2py. I have a few questions as I
> tried a few things. Before I state those, a million thanks to Massimo for
> creating web2py; and to Anthony and others who have helped me here to get
> out of it when I am stuck.
>
> Questions about DAL
> ------------------------------
>
> (1) If I am using DAL to create tables, is it true that I should not go
> and make changes to the database from mysql prompt?
>
> For example, I created a table using DAL, then went to mysql prompt and
> deleted the table. When I tried to run the code again, I kept getting an
> error saying that "table already exists". I looked up on these forums and
> there were some suggestions about deleting the .table file related to that
> table in the databases folder of the application. I did that and still kept
> getting the same error.
>
> (2) In the documentation, there is a suggestion for using
> db.tablename.truncate() for dropping the table.
>
> I tried the following:
>
> (a) Enter "python web2py.py -S applicationname". This gives the iPython
> prompt.
> (b) Enter db = DAL(DAL('mysql://root:mypasswd@localhost/ultimatumG')
>
> At this point, when I enter db.tablename.drop() (where tablename is the
> name of a table in ultimatumG database) I get an error saying :
>
> 'DAL' object has no attribute tablename.
>
> How do I make small changes to database? It appears I cannot do them from
> mysql prompt because that confuses the application and for some reason I am
> unable to connect from iPython prompt.
>
> I am using version 2.0.9 (2012-09-13) of web2py.
>
> Thanks for your help.
>
>
--