Hi Massimo,
I am connecting to an existing Microsoft SQL database through DAL ----- db
= DAL('mssql4://sa:password@localhost/Unity'). This connection seems to be
connected because I also created the fake table, and the table was created.
I can view this table from both Microsoft SQL Manager, and Web2py database
admistrator. I can access this table by using db().select(db......
However, I can not figure out how to access the existing tables which were
created outside Web2py. I kept reading the manual related to Legacy
database, and could find anything ...
I also tried to call db.define_table with migrate = false, and it is shown
up in Web2py database admistrator page. BUT can not query it, it keeps
saying DAL object has not attribute...
Thanks for helping.
Vu
On Sunday, September 30, 2012 at 10:42:48 AM UTC-7, Massimo Di Pierro wrote:
>
> 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.
>>
>>
--
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].
For more options, visit https://groups.google.com/d/optout.