Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (16 sloc) 706 Bytes
layout title
default
Multiple Databases

Multiple Databases

Problem

You want to access multiple databases in a single project.

Solution

webpy 0.3 supports multiple databases by removing the database from a part of the "web" module, and making it a more typical object. For example:

import web

db1 = web.database(dbn='mysql', db='dbname1', user='foo')
db2 = web.database(dbn='mysql', db='dbname2', user='foo')

print db1.select('foo', where='id=1')
print db2.select('bar', where='id=5')

insert, update, delete and query methods can also be used in the similar way.

Of course, you can use 'host' and 'port' to specify server address and listen port.

Something went wrong with that request. Please try again.