Permalink
Browse files

cleared an empty code box

  • Loading branch information...
1 parent b38f0e4 commit ca18dd6acc2692a25074fe834eafcee33e12effe foxbunny committed with anandology Dec 29, 2009
Showing with 23 additions and 25 deletions.
  1. +23 −25 cookbook/where_dict.md
@@ -5,29 +5,27 @@ title: Using a dictionary as where clause
# Using a dictionary as where clause
-Problem
--------
-
-You want to create a dictionary of where clauses dynamically and use it in a query.
-
-Solution
---------
-
- >>> import web
- >>> db = web.database(dbn='postgres', db='mydb', user='postgres')
- >>> where_dict = {'col1': 1, col2: 'sometext'}
- >>> db.delete('mytable', where=web.db.sqlwhere(where_dict), _test=True)
- <sql: "DELETE FROM mytable WHERE col1 = 1 AND col2 = 'sometext'">
-
-
-
-Explanation
------------
-
-`web.db.sqlwhere` takes a Python dictionary as an argument and converts it into a string useful for where clause in different queries. You can also use an optional `grouping` argument to define the exact gouping of the individual keys. For instance:
-
- >>> import web
- >>> web.db.sqlwhere({'a': 1, 'b': 2}, grouping=' OR ')
- 'a = 1 OR b = 2'
-
+Problem
+-------
+
+You want to create a dictionary of where clauses dynamically and use it in a query.
+
+Solution
+--------
+
+ >>> import web
+ >>> db = web.database(dbn='postgres', db='mydb', user='postgres')
+ >>> where_dict = {'col1': 1, col2: 'sometext'}
+ >>> db.delete('mytable', where=web.db.sqlwhere(where_dict), _test=True)
+ <sql: "DELETE FROM mytable WHERE col1 = 1 AND col2 = 'sometext'">
+
+Explanation
+-----------
+
+`web.db.sqlwhere` takes a Python dictionary as an argument and converts it into a string useful for where clause in different queries. You can also use an optional `grouping` argument to define the exact gouping of the individual keys. For instance:
+
+ >>> import web
+ >>> web.db.sqlwhere({'a': 1, 'b': 2}, grouping=' OR ')
+ 'a = 1 OR b = 2'
+
Default for `grouping` is `' AND '`.

0 comments on commit ca18dd6

Please sign in to comment.