On Monday, 23 January 2017 15:20:59 UTC-8, Louis De Lange wrote:
>
> This is a question about writing records to 3rd party databases such as 
> Meteotemplate.  
>
> In addition to WeeWX I have a site running Meteotemplate with it's own 
> MySQL database.  The normal way of filling the Meteotemplate database is 
> through clientraw.txt or realtime.txt and cron jobs, but I decided to write 
> a service that automatically populates the Meteotemplate database on each 
> archive period of WeeWX.  
>
>
> So the next thing I want to do is to create a manual entry point into the 
meteotemplate.py script to compare the weewx database and the meteotemplate 
database and backfill any missing data in the meteotemplate database. 
 Following the database access instructions in the customization guide and 
stealing from other sources I came up with the following script at the end 
of my meteotemplate.py update script:
 
# simple interface for manual database backfill and diagnostics
#
# cd /home/weewx
# PYTHONPATH=bin python bin/user/meteotemplate.py

if __name__ == "__main__":
    usage = """%prog"""

    def main():
        print "This is a test for command line access"
        db_manager = weewx.manager.open_manager_with_config(config_dict, 
data_binding='wx_binding')
        # SQL Query to get all weewx timestamps since a specific time:
        db_manager.getSql("SELECT dateTime FROM %s "\
                          "WHERE dateTime>?" % db_manager.table_name, 
(1484899200))
    main()

When I execute this snippet from the command line I get the following:

  File "bin/user/meteotemplate.py", line 168, in main
    db_manager = weewx.manager.open_manager_with_config(config_dict, 
data_binding='wx_binding')
NameError: global name 'config_dict' is not defined

I know that I need to somehow initialize and import config_dict but I am 
not sure how to do that outside of class definitions. Any of the examples 
I've looked at creates a subclass of something where config_dict is 
defined, but I don't think I can do that in the 'main()' script.

Can anyone point me in the right direction?

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to