José, Just because the database was not created by web2py does not automatically mean that you cannot access it through the DAL. As long as the table you want to get at has an auto-increment integer primary key field you can define that table through the DAL - even if the identity field is not named 'id' as would normally be the case if web2py had created the table itself. Provided that the table does have the expected type of primary key field, just set the field type to 'id' and you're all set (don't think that type is actually mentioned in the book, but it does work). I'd also recommend that you set the table not to use migrations to avoid accidentally making an unintended change to the existing table. So something like this:
external_db_config = dict(username = 'your_username', password = 'superS3cret!', server = 'external_db_hostname', database='my_external_db') external_db = DAL( 'mssql://%(username)s:%(password)s@%(server)s/%(database)s' % external_db_config) external_db.define_table('legacy_table', FIELD('id_field', 'id'), #that's it even if it isn't named id web2py will now know it is the primary key now FIELD('name', 'string'), migrate = False ) So, if you're external database is actually the same database that the rest of your web2py app is using, just use the above and continue to take full advantage all all of the auto-magical web2py SQLFORM goodness as if you'd let web2py create that database table itself. Now if you are actually using two *separate *databases then you'll have a slightly harder time. However, it still isn't impossible to get what you are after - just refer to my original suggestion that used OPTION() and SELECT() to manually build your combobox options. On Friday, September 19, 2014 2:24:44 PM UTC-5, José Eloy wrote: > > Thanks Brian and Carlos for the answer and sorry for my delay. > > "external database" means it's a database not created by Web2py. The > matter is I'd like to reference a web2py table with another table from the > "external database". I know that this is not possible, but what could be > the best way to load a combobox (using a SQLForm) with data from a field > from that external database? > > I hope you can understand me, my english is not very good. > > Regards. > > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.