Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 27 lines (18 sloc) 0.797 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
17 mydb1 = web.database(dbn='mysql', db='dbname1', user='foo')
18 mydb2 = web.database(dbn='mysql', db='dbname2', user='foo')
19
20 All of the former database methods work on these objects, such as:
21
22 * select('table_name', where="foo = bar")
23 * insert('table_name', foo="bar", baz="asdf")
24 * update('table_name', where="id = 10", foo="bar")
25 * query('table_name', "SELECT * FROM users JOIN friends WHERE users.id = friends.id")
26
27 See the database module for more information.
Something went wrong with that request. Please try again.