say you have two databases db1=DAL(...) db2=DAL(...)
and they contains a similar table table1=db1.define_table('person',Field('name')) table2=db2.define_table('person',table1) # same fields a table1 and you want all records from both rows=db(table1.id>0).select()&db(table2.id>0).select() now you can sort them by name rows=rows.sort(lambda row: row.name) or you can get all records without duplicates rows=db(table1.id>0).select()|db(table2.id>0).select() and filter those that start with 'a' rows=rows.find(lambda row: row.name.startswith('a')) etc. The last 4 operations are performed at the web2py level, not the db level so they may use lots memory and IO. Massimo On Oct 2, 3:59 am, Alexandre Andrade <alexandrema...@gmail.com> wrote: > (this text was translated by google) > > Hi folks, > > I'll have to develop an application on my service that uses data from > several databases. > > I'm the one time looking for a way to solve this problem within the web2py > and the solution is pictured below. > > I wonder if anyone has a similar situation and considerations that would > have the following possible solution: > > -------------------------------------------------- > -------------------------------------------------- > ------------------ > > A Universal Interface for Databases is a webservice that centralizes access > to all databases of a company. > > Although in most cases applications use only one database, on the whole, a > company has multiple databases. > > In many cases they are redundant and have duplicate information in several > ways. > > This means that in practice, developers or duplicate the information have to > create ad hoc solutions to integrate systems. > > This also requires that to generate management information, there is a need > to create "data warehouses" to gather all the information and extract > reports. > > The purpose of the UDI is to serve as sole access to all information from > all databases of the company. > > Thus, the developer connects your application to a single point, and calls > through the UDI all the information your application needs, as well as > forward all information necessary for the UDI provide storage. > > The functions of the IDU are: > > 0. Manage the connection and communication with all legacy databases. > 1. List all databases, tables and data fields available, with metadata, if > any > 2. Allow queries that retrieve information from different databases, as if > they were one (least of records) > 3. Let me set the mapping between the data required by the application > with the various databases in a visual interface, even to the programmer. > 4. Store information received as a single record distributing it in > different fields of databases and tables if needed. > 5. Setting a standard database application, which will store the mappings > of the data with all other existing databases, and to store the application > specific data, not available elsewhere. > 6.Possuir a tool for generating reports and dashboards for nontechnical > users. > > In web2py, it would be a standalone application as well as the admin, and > would be used in applications as a substitute for DAL, yet remains easy to > generate the forms. > > The big difference, and allows using data from several sources, is that the > data (tables and fields) present in other banks would not need to be > defined, but only mapped, and both the mapping and the possible creation of > tables and fields would be in a graphical interface. > > -- > Atenciosamente > > -- > ========================= > Alexandre Andrade > Hipercenter.com