mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 09:54:31 +02:00
Improved code compilation pattern, closes #472
This commit is contained in:
parent
23ef1d6c20
commit
a46a5e3a9e
3 changed files with 24 additions and 8 deletions
|
|
@ -1359,12 +1359,9 @@ The following example adds a new ``score`` column, then updates it to list a ran
|
|||
random.seed(10)
|
||||
|
||||
def convert(value):
|
||||
global random
|
||||
return random.random()
|
||||
'
|
||||
|
||||
Note the ``global random`` line here. Due to the way the tool compiles Python code, this is necessary to ensure the ``random`` module is available within the ``convert()`` function. If you were to omit this you would see a ``NameError: name 'random' is not defined`` error.
|
||||
|
||||
.. _cli_convert_recipes:
|
||||
|
||||
sqlite-utils convert recipes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue