Permalink
Browse files

edit

  • Loading branch information...
1 parent b2ca622 commit d7db15f6f9edacd2fb0246f45ab373109e22cfd6 @irrelative irrelative committed with anandology May 17, 2008
Showing with 22 additions and 0 deletions.
  1. +22 −0 cookbook/multidbs.md
View
22 cookbook/multidbs.md
@@ -0,0 +1,22 @@
+---
+layout: default
+title: Multiple Databases
+---
+
+# Multiple Databases
+
+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
+
+ mydb1 = web.database(dbn='mysql', db='dbname1', user='foo')
+ mydb2 = web.database(dbn='mysql', db='dbname2', user='foo')
+
+All of the former database methods work on these objects, such as:
+
+* select('table_name', where="foo = bar")
+* insert('table_name', foo="bar", baz="asdf")
+* update('table_name', where="id = 10", foo="bar")
+* query('table_name', "SELECT * FROM users JOIN friends WHERE users.id = friends.id")
+
+See the database module for more information.

0 comments on commit d7db15f

Please sign in to comment.