diff --git a/doc/topics/advanced_usage.rst b/doc/topics/advanced_usage.rst index 0af10cb..d35bbdb 100644 --- a/doc/topics/advanced_usage.rst +++ b/doc/topics/advanced_usage.rst @@ -21,12 +21,12 @@ The return value will vary based on the type of query. Embedded Python --------------- DQL supports the use of python expressions anywhere that you would otherwise -have to specify a data type. Just surround the python with backticks. Create -your variable scope as a dict and pass it to the engine with the commands: +have to specify a data type by surrounding the python with backticks. Set the +variable scope on the engine and run your query: .. code-block:: python - >>> engine.scope = {'foo1': 1, 'foo2': 2} + >>> engine.scope.update(foo1=1, foo2=2) >>> engine.execute("INSERT INTO foobars (foo) VALUES (`foo1`), (`foo2`)") The interactive client has a special way to modify the scope. You can switch diff --git a/doc/topics/queries/update.rst b/doc/topics/queries/update.rst index bfc7527..a1d4428 100644 --- a/doc/topics/queries/update.rst +++ b/doc/topics/queries/update.rst @@ -70,10 +70,9 @@ row dict directly: .. code-block:: sql - us-west-1> UPDATE foobars SET foo = m`if row.get('bar'): - > return bar + 1 - > else: - > return 1`; + us-west-1> UPDATE foobars SET foo = `row.get('bar', 0) + 1` -This syntax will NOT WORK if you are using the ``KEYS IN`` form of the query, -as that performs the update without doing any table reads. +.. warning:: + + This syntax will not work if you are using the ``KEYS IN`` form of the + query, as that performs the update without doing any table reads.