Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 25 lines (16 sloc) 0.706 kB
d7db15f @irrelative edit
irrelative authored
1 ---
2 layout: default
3 title: Multiple Databases
4 ---
5
6 # Multiple Databases
7
94919cd @irrelative edit
irrelative authored
8 ## Problem
9 You want to access multiple databases in a single project.
10
11 ## Solution
12
d7db15f @irrelative edit
irrelative authored
13 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:
14
15 import web
16
ca1d0bb @anandology edit
anandology authored
17 db1 = web.database(dbn='mysql', db='dbname1', user='foo')
18 db2 = web.database(dbn='mysql', db='dbname2', user='foo')
268f0c3 @anandology edit
anandology authored
19
20 print db1.select('foo', where='id=1')
21 print db2.select('bar', where='id=5')
ca1d0bb @anandology edit
anandology authored
22
23 insert, update, delete and query methods can also be used in the similar way.
d7db15f @irrelative edit
irrelative authored
24
6fd5878 edit
6yf authored
25 Of course, you can use 'host' and 'port' to specify server address and listen port.
Something went wrong with that request. Please try again.