Hi Stan, thank you. Let's see if I understand this correctly. You want to write code that generates python code from an Oracle "CREATE TABLE ...." string. Am I correct?
This would be interesting by there are some limitations. The table must have an integer field "ID" and a trigger that does auto- increment. When you start from web2py, it creates it for you. Moreover all references must reference this the ID field. If your tables are compliant and you have a some data structure like tables=[ {'tablename':'puppy', 'fields': [{'fieldname':'name','type':'string','length':32}]}, ] then you can do for table in tables: db.define_table(table['name'],*[SQLField(**f) for f in table['fields']]) Massimo On Oct 15, 2:39 pm, Stan <[EMAIL PROTECTED]> wrote: > Massimo, > > Congratulations on an extremely impressive product! > > I would like to dig a little deeper into the question of attaching to > existing databases. I have a fairly large Oracle database with many > tables. I would like to 'attach' the web2py framework to this > database (I would probably need to define as many as 50 tables, some > with hundreds of fields). A brief review of the syntax would indicate > that it could be possible to utilize (consume) the DDL for a table, > and generate the python code definition for the table. Once this > utility was available for one database, others should be fairly simple > to adapt. I am particularly interested in consuming Oracle tables. > Much of the information is likely within your epydocs link and > possibly the book, but is there a design document for a database table > class? > > I'd be interested in your thoughts as to problems and potential. > > Thank you very much, > > Stan > > On Oct 15, 11:58 am, mdipierro <[EMAIL PROTECTED]> wrote: > > > web2py ONLY talks to the tabase engine in SQL and SQL does not prove a > > means to query for table structure. > > > If you want to access an existing table you can, if and only if the > > table has an ID field. You need to (re)define the table with > > migrate=False. You do not need to define the entire database. You only > > need define those tables that you need and those fields of the tables > > that you plan to access (excluding ID). > > > Massimo > > > On Oct 15, 10:49 am, JorgeRpo <[EMAIL PROTECTED]> wrote: > > > > What if I want to use web2py to modify data from some other running > > > app (php Drupal, for instance). Do I need to define all the model? or > > > is there some kind of tool to figure it out.. > > > > On Oct 15, 10:20 am, mdipierro <[EMAIL PROTECTED]> wrote: > > > > > In every case you need to choose a master application. > > > > If you use SQLite, the master app will do > > > > > db=SQLDB('sqlite://stoarge.db') > > > > db.define_table(.....) > > > > > the other apps will do > > > > > db=SQLDB('sqlite://../../masterapp/databases/stoarge.db') > > > > db.define_table(.....,migrate=False) #### important! > > > > > If you use anything other than SQlite, db=SQLDB(....) should all use > > > > the same connection string to the same database engine. > > > > > The master needs to define all tables, the other apps need to define > > > > only the tables the use. > > > > > Different browser render pages differently. Most of the > > > > inconsistencies are dues to the use of JS, invalid CSS or invalid > > > > HTML. You can test for valid HTML and CSS using w3c validation pages > > > > online. > > > > > Massimo > > > > > On Oct 15, 9:26 am, tommy <[EMAIL PROTECTED]> wrote: > > > > > > How does web2py application to access the database in other > > > > > application? We have three applicaitons, two web applications > > > > > developed by web2py, and another application developed by python. > > > > > Three applications try to access one database. I don't know how to > > > > > setup the database in which application. Can someone help me? > > > > > > By the way, here is my another issue. My web pages look good when I > > > > > use firefox, but when I use IE to browse the pages, the pages looks > > > > > mess. Any idea?- Hide quoted text - > > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---