python web2py.py -M -N -S kb -R script.py

On Mar 7, 7:53 am, Johann Spies <johann.sp...@gmail.com> wrote:
> I want to run a script in the commandline shell to insert records into the
> database, but have a problem handling the namespace.
>
> When I try to run it with the '%run' option or do a 'from <script>  import
> *' makes no difference: I get the namespace error in the subject line:
>
> /home/js/web2py/lees_isi_xml6.py in plaas_artikel(rekord)
>     352     categories = rekord['categories']
>     353     ut = item['ut'][0]
> --> 354     print db.tables()
>     355     if db(db.isi_articles.ut == ut).count() == 0:
>     356         titel = item['item_title'][0]
>
> NameError: global name 'db' is not defined
>
> But when I do a 'db.tables()' in the same shell, there is no problem.
>
> I have started the shell with
>
> python web2py.py -M -S kb
>
> How do I get web2py to run this script?
>
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
>                                                     2 Pet. 1:2b,3a

Reply via email to