From f87cd696b324063dac73bf5cbae694e0f96fa4d5 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Wed, 7 Nov 2012 17:53:10 +0000 Subject: [PATCH] Now allows the stats and main archive database to be combined into one database. V2.0.2rc1 --- bin/weewx/__init__.py | 2 +- bin/weewx/stats.py | 9 ++++++--- docs/usersguide.htm | 30 ++++++++++++++++++++++++++++++ weewx.conf | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/bin/weewx/__init__.py b/bin/weewx/__init__.py index 4af009a3..30c4bd3f 100644 --- a/bin/weewx/__init__.py +++ b/bin/weewx/__init__.py @@ -12,7 +12,7 @@ """ import time -__version__="2.0.1" +__version__="2.0.2rc1" # Holds the program launch time in unix epoch seconds: # Useful for calculating 'uptime.' diff --git a/bin/weewx/stats.py b/bin/weewx/stats.py index 54e7b230..0df17975 100644 --- a/bin/weewx/stats.py +++ b/bin/weewx/stats.py @@ -171,7 +171,7 @@ class StatsDb(object): stats = StatsDb.open(stats_db_dict) # The database exists and has been initialized. Return it. return stats - except weedb.OperationalError, weewx.UninitializedDatabase: + except (weedb.OperationalError, weewx.UninitializedDatabase): pass # First try to create the database. If it already exists, an exception @@ -594,9 +594,12 @@ class StatsDb(object): # Some stats database have schemas for heatdeg and cooldeg (even though # they are not used) due to an earlier bug. Filter them out. Also, - # filter out the metadata table: - stats_types = [s for s in raw_stats_types if s not in ['heatdeg','cooldeg','metadata']] + # filter out the metadata table. In case the same database is being used + # for the archive data, filter out the 'archive' database. + stats_types = [s for s in raw_stats_types if s not in ['heatdeg','cooldeg','metadata', 'archive']] + if not stats_types: + raise weedb.OperationalError("Uninitialized stats database") return stats_types diff --git a/docs/usersguide.htm b/docs/usersguide.htm index 82c5d9f3..2a455f74 100644 --- a/docs/usersguide.htm +++ b/docs/usersguide.htm @@ -668,6 +668,36 @@ Mutating actions will request confirmation before proceeding.

$WEEWX_ROOT/bin/config_vp.py $WEEWX_ROOT/weewx.conf --set-bucket=2

+

Configuring MySql

+

This section can be ignored if you are not using MySQL.

+

Assuming that you use the default database configurations, your + [Databases] + section will look like:

+
	[[archive_mysql]]
+		host = localhost
+		user = weewx
+		password = weewx
+		database = weewx
+		driver = weedb.mysql
+		
+	[[stats_mysql]]
+		host = localhost
+		user = weewx
+		password = weewx
+		database = stats
+		driver = weedb.mysql
+

You will need to give the necessary permissions for databases 'weewx' + and 'stats' to whatever MySQL + user you choose, by default, user 'weewx'. Here would be the + necessary permissions:

+
mysql> CREATE USER 'weewx'@'localhost' IDENTIFIED BY 'weewx';
+mysql> GRANT select, update, create, delete, insert ON weewx.* TO weewx@localhost;
+mysql> GRANT select, update, create, delete, insert ON stats.* TO weewx@localhost;
+

This assumes user 'weewx' would have + password 'weewx'. If you wish, databases 'weewx' + and 'stats' can be combined into one + database, although this will make it harder to drop the latter + should you need to rebuild it at a later time.

Editing the configuration file weewx.conf

Station specific information is set in the configuration file $WEEWX_ROOT/weewx.conf. (There is another diff --git a/weewx.conf b/weewx.conf index 99aa12b0..8b8056e5 100644 --- a/weewx.conf +++ b/weewx.conf @@ -32,7 +32,7 @@ WEEWX_ROOT = /home/weewx socket_timeout = 20 # Current version -version = 2.0.1 +version = 2.0.2rc1 ############################################################################################