wee_database: ImportError

130 views
Skip to first unread message

Eric Gammeter

unread,
Feb 25, 2020, 9:11:40 AM2/25/20
to weewx-user

Goal:
Wanting to switch from sqlite to MySql database.

I am consulting the github /weewx/wiki "Usingwee_database".

The --dry-run doesn't show any error. 


pi@raspberrypi:~ $ wee_database --transfer --dest-binding=dest_binding --dry-run
Using configuration file /etc/weewx/weewx.conf
Using database binding 'wx_binding', which is bound to database 'archive_sqlite'
Transfer 9177 records from source database 'weewx.sdb' to destination database 'weewx'.
Dry run, nothing done.
pi@raspberrypi:~ $ wee_database --transfer --dest-binding=dest_binding
Using configuration file /etc/weewx/weewx.conf
Using database binding 'wx_binding', which is bound to database 'archive_sqlite'
Transfer 9177 records from source database 'weewx.sdb' to destination database 'weewx' (y/n)? y
Error accessing destination database 'weewx'.
Nothing done. Aborting.
Traceback (most recent call last):
  File "/usr/bin/wee_database", line 794, in <module>
    main()
  File "/usr/bin/wee_database", line 159, in main
    transferDatabase(config_dict, db_binding, options)
  File "/usr/bin/wee_database", line 410, in transferDatabase
    schema=dest_manager_dict['schema']) as dest_manager:
  File "/usr/share/weewx/weewx/manager.py", line 128, in open_with_create
    connection = weedb.connect(database_dict)
  File "/usr/share/weewx/weedb/__init__.py", line 86, in connect
    __import__(db_dict['driver'])
  File "/usr/share/weewx/weedb/mysql.py", line 10, in <module>
    import MySQLdb
ImportError: No module named MySQLdb

Thomas Keffer

unread,
Feb 25, 2020, 10:59:49 AM2/25/20
to weewx-user
For some reason, the Python MySQL client library has not been installed. Try this:

sudo apt-get install mysql-client
sudo apt-get install python-mysqldb

-tk

--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/86fc5cde-69a0-4ab3-aa5c-f2c7f0c1559a%40googlegroups.com.

Eric Gammeter

unread,
Feb 25, 2020, 2:30:31 PM2/25/20
to weewx-user

Hmm  . 
FYI:  The mysql-client has been replaced with the mariadb-client-10.0.
Still not working. 

wee_database --transfer --dest-binding=dest_binding
Using configuration file /etc/weewx/weewx.conf
Using database binding 'wx_binding', which is bound to database 'archive_sqlite'
Transfer 9187 records from source database 'weewx.sdb' to destination database 'weewx' (y/n)? y

Error accessing destination database 'weewx'.
Maybe it does not exist (MySQL) or is incorrectly defined in weewx.conf?
Nothing done. Aborting.
Message has been deleted

Eric Gammeter

unread,
Feb 25, 2020, 3:14:09 PM2/25/20
to weewx-user
Yes.  Both commands were issued. 



On Tuesday, February 25, 2020 at 9:11:40 AM UTC-5, Eric Gammeter wrote:

Thomas Keffer

unread,
Feb 25, 2020, 6:50:06 PM2/25/20
to weewx-user
You did both commands and the MySQL driver is still not available?

What happens if you do

python -c "import MySQLdb"
python -c "import weedb.mysql"

If either of these fail, then the MySQL drivers were not installed. 

NB: there may now be separate drivers for the MariaDB database, but we don't support them. The assumption is that the MySQL drivers will still work. If that's not true, then we have a problem!

-tk


--
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 weewx-user+...@googlegroups.com.

gjr80

unread,
Feb 25, 2020, 7:19:34 PM2/25/20
to weewx-user
Is this an issue with missing python packages/drivers or something else? I must admit I took the following to indicate more of database not found/credential issue rather than a missing package/driver issue.

wee_database --transfer --dest-binding=dest_binding
Using configuration file /etc/weewx/weewx.conf
Using database binding 'wx_binding', which is bound to database 'archive_sqlite'
Transfer 9187 records from source database 'weewx.sdb' to destination database 'weewx' (y/n)? y

Error accessing destination database 'weewx'.
Maybe it does not exist (MySQL) or is incorrectly defined in weewx.conf?
Nothing done. Aborting

I have been using MariaDB for a while now and have not needed to install anything other than the pre-reqs listed in the docs. MariaDB seems to default now to using some means of authentication other than user/password (I've seen reference to authentication using the unix_socket plugin ?). One thing I have done, and perhaps it is just a personal preference, is to change this back to user/password authentication on my installs. I guess I would be asking the user can he access MariaDB from the command line with the credentials in weewx.conf.

Gary
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.

Eric Gammeter

unread,
Feb 27, 2020, 3:46:17 PM2/27/20
to weewx-user
That did the trick Tom.  Thank you much.  I am still really enjoying your WEEWX program!  

/Eric G.  




On Tuesday, February 25, 2020 at 9:11:40 AM UTC-5, Eric Gammeter wrote:

Eric Gammeter

unread,
Mar 3, 2020, 11:47:31 AM3/3/20
to weewx-user
My error:  I was wrong on my situation-  it is not fixed.  

I have attached debug.info file with all the particulars.    

I am attempting to convert my existing sqlite weewx db file to MySQL and then migrate it over to a new RaspberryPi 4 platform.   
/EG





On Tuesday, February 25, 2020 at 9:11:40 AM UTC-5, Eric Gammeter wrote:
debug.info

Thomas Keffer

unread,
Mar 3, 2020, 12:38:32 PM3/3/20
to weewx-user
$ sudo wee_database --transfer --dest-binding = dest_binding --dry-run

Traceback (most recent call last):
  File "/usr/bin/wee_database", line 794, in <module>
    main()
  File "/usr/bin/wee_database", line 133, in main
    config_path, config_dict = weecfg.read_config(options.config_path, args)
  File "/usr/share/weewx/weecfg/__init__.py", line 173, in read_config
    locations=locations, file_name=file_name)
  File "/usr/share/weewx/weecfg/__init__.py", line 147, in find_file
    raise IOError("%s is not a file" % file_path)
IOError: dest_binding is not a file

Is dest_binding defined in your configuration file?

 $ sudo python -c "import weedb.mysql"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named weedb.mysql

This is probably a PYTHONPATH problem. 

-tk

--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/160ebdf6-3c35-4c85-9902-85d0685b9034%40googlegroups.com.

Eric Gammeter

unread,
Mar 3, 2020, 1:07:54 PM3/3/20
to weewx-user
Yes: here it is from weewx.conf file:


   [[dest_binding]]
        database = archive_mysql
        table_name = archive
        manager = weewx.wxmanager.WXDaySummaryManager
        schema = schemas.wview.schema



On Tuesday, February 25, 2020 at 9:11:40 AM UTC-5, Eric Gammeter wrote:

Thomas Keffer

unread,
Mar 3, 2020, 2:24:38 PM3/3/20
to weewx-user
Looking a little bit closer at the command you used, the syntax is not quite right. Instead of

sudo wee_database --transfer --dest-binding = dest_binding --dry-run

your want

sudo wee_database --transfer --dest-binding=dest_binding --dry-run

-tk

--
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 weewx-user+...@googlegroups.com.

Eric Gammeter

unread,
Mar 3, 2020, 3:26:36 PM3/3/20
to weewx-user
OK-  That was it!  Nice catch of *my* oversight tk.  
/EG  


On Tuesday, February 25, 2020 at 9:11:40 AM UTC-5, Eric Gammeter wrote:
Reply all
Reply to author
Forward
0 new messages