{"action":"created","issue":{"url":"https://api.github.com/repos/tcgoetz/GarminDB/issues/18","repository_url":"https://api.github.com/repos/tcgoetz/GarminDB","labels_url":"https://api.github.com/repos/tcgoetz/GarminDB/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/tcgoetz/GarminDB/issues/18/comments","events_url":"https://api.github.com/repos/tcgoetz/GarminDB/issues/18/events","html_url":"https://github.com/tcgoetz/GarminDB/issues/18","id":365925391,"node_id":"MDU6SXNzdWUzNjU5MjUzOTE=","number":18,"title":"sqlite3.IntegrityError during rebuild_db","user":{"login":"dalepharo","id":16614667,"node_id":"MDQ6VXNlcjE2NjE0NjY3","avatar_url":"https://avatars1.githubusercontent.com/u/16614667?v=4","gravatar_id":"","url":"https://api.github.com/users/dalepharo","html_url":"https://github.com/dalepharo","followers_url":"https://api.github.com/users/dalepharo/followers","following_url":"https://api.github.com/users/dalepharo/following{/other_user}","gists_url":"https://api.github.com/users/dalepharo/gists{/gist_id}","starred_url":"https://api.github.com/users/dalepharo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dalepharo/subscriptions","organizations_url":"https://api.github.com/users/dalepharo/orgs","repos_url":"https://api.github.com/users/dalepharo/repos","events_url":"https://api.github.com/users/dalepharo/events{/privacy}","received_events_url":"https://api.github.com/users/dalepharo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-10-02T14:29:24Z","updated_at":"2018-10-04T06:16:29Z","closed_at":null,"author_association":"NONE","body":"Hi, \r\nI'm using this on bash for windows, and the scrape of fit files works perfectly, but when importing/rebuilding the below error is generated. this happens for all .fit files:\r\n\r\n> INFO:import_garmin.py:Debug: False English units: True\r\nINFO:/home/dale/GarminDB/FileProcessor.pyc:Reading directory: /root/HealthData/FitFiles/2018_Monitoring/\r\nINFO:GarminDB.GarminDB:GarminDB: {'db_type': 'sqlite', 'db_path': '/root/HealthData/DBs'} debug: -1\r\nINFO:GarminDB.MonitoringDB:MonitoringDB: {'db_type': 'sqlite', 'db_path': '/root/HealthData/DBs'} debug: -1\r\nINFO:GarminDB.ActivitiesDB:ActivitiesDB: {'db_type': 'sqlite', 'db_path': '/root/HealthData/DBs'} debug: -1\r\nINFO:/home/dale/GarminDB/FitFileProcessor.pyc:Debug: False English units: True\r\nINFO:/home/dale/GarminDB/FitFileProcessor.pyc:Importing /root/HealthData/FitFiles/2018_Monitoring//24287393166.fit (2018-09-01 06:39:59) [FileType.monitoring_b] with message types: [<MessageType.file_id: 0>, <MessageType.device_info: 23>, <MessageType.software: 35>, <MessageType.monitoring_info: 103>, <MessageType.monitoring: 55>, <UnknownMessageType.unknown_211: 211>]\r\nTraceback (most recent call last):\r\n  File \"import_garmin.py\", line 301, in <module>\r\n    main(sys.argv[1:])\r\n  File \"import_garmin.py\", line 287, in main\r\n    gfd.process_files(db_params_dict)\r\n  File \"import_garmin.py\", line 79, in process_files\r\n    fp.write_file(Fit.File(file_name, self.english_units))\r\n  File \"/home/dale/GarminDB/FitFileProcessor.py\", line 62, in write_file\r\n    self.write_message_types(fit_file, fit_file.message_types())\r\n  File \"/home/dale/GarminDB/FitFileProcessor.py\", line 57, in write_message_types\r\n    self.write_message_type(fit_file, message_type)\r\n  File \"/home/dale/GarminDB/FitFileProcessor.py\", line 44, in write_message_type\r\n    function(fit_file, message_type, messages)\r\n  File \"/home/dale/GarminDB/FitFileProcessor.py\", line 37, in write_generic\r\n    function(fit_file, message)\r\n  File \"/home/dale/GarminDB/FitFileProcessor.py\", line 332, in write_monitoring_info_entry\r\n    GarminDB.MonitoringInfo.find_or_create(self.garmin_mon_db, entry)\r\n  File \"/home/dale/GarminDB/HealthDB/DB.py\", line 231, in find_or_create\r\n    DB.commit(session)\r\n  File \"/home/dale/GarminDB/HealthDB/DB.py\", line 58, in commit\r\n    session.commit()\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py\", line 943, in commit\r\n    self.transaction.commit()\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py\", line 467, in commit\r\n    self._prepare_impl()\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py\", line 447, in _prepare_impl\r\n    self.session.flush()\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py\", line 2254, in flush\r\n    self._flush(objects)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py\", line 2380, in _flush\r\n    transaction.rollback(_capture_exception=True)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py\", line 66, in __exit__\r\n    compat.reraise(exc_type, exc_value, exc_tb)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py\", line 2344, in _flush\r\n    flush_context.execute()\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py\", line 391, in execute\r\n    rec.execute(self)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py\", line 556, in execute\r\n    uow\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py\", line 181, in save_obj\r\n    mapper, table, insert)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py\", line 830, in _emit_insert_statements\r\n    execute(statement, multiparams)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py\", line 948, in execute\r\n    return meth(self, multiparams, params)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py\", line 269, in _execute_on_connection\r\n    return connection._execute_clauseelement(self, multiparams, params)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py\", line 1060, in _execute_clauseelement\r\n    compiled_sql, distilled_params\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py\", line 1200, in _execute_context\r\n    context)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py\", line 1413, in _handle_dbapi_exception\r\n    exc_info\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py\", line 265, in raise_from_cause\r\n    reraise(type(exception), exception, tb=exc_tb, cause=cause)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py\", line 1193, in _execute_context\r\n    context)\r\n  File \"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py\", line 509, in do_execute\r\n    cursor.execute(statement, parameters)\r\nsqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) NOT NULL constraint failed: monitoring_info.file_id [SQL: u'INSERT INTO monitoring_info (timestamp, file_id, activity_type, resting_metabolic_rate, cycles_to_distance, cycles_to_calories) VALUES (?, ?, ?, ?, ?, ?)'] [parameters: ('2018-09-01 06:40:00.000000', None, 'walking', 2447, 1.729, 0.0677344808351263)] (Background on this error at: http://sqlalche.me/e/gkpj)\r\nmake: *** [import_monitoring] Error 1"},"comment":{"url":"https://api.github.com/repos/tcgoetz/GarminDB/issues/comments/426897918","html_url":"https://github.com/tcgoetz/GarminDB/issues/18#issuecomment-426897918","issue_url":"https://api.github.com/repos/tcgoetz/GarminDB/issues/18","id":426897918,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjg5NzkxOA==","user":{"login":"dalepharo","id":16614667,"node_id":"MDQ6VXNlcjE2NjE0NjY3","avatar_url":"https://avatars1.githubusercontent.com/u/16614667?v=4","gravatar_id":"","url":"https://api.github.com/users/dalepharo","html_url":"https://github.com/dalepharo","followers_url":"https://api.github.com/users/dalepharo/followers","following_url":"https://api.github.com/users/dalepharo/following{/other_user}","gists_url":"https://api.github.com/users/dalepharo/gists{/gist_id}","starred_url":"https://api.github.com/users/dalepharo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dalepharo/subscriptions","organizations_url":"https://api.github.com/users/dalepharo/orgs","repos_url":"https://api.github.com/users/dalepharo/repos","events_url":"https://api.github.com/users/dalepharo/events{/privacy}","received_events_url":"https://api.github.com/users/dalepharo/received_events","type":"User","site_admin":false},"created_at":"2018-10-04T06:16:29Z","updated_at":"2018-10-04T06:16:29Z","author_association":"NONE","body":"ok, importing to db is working great now for monitoring.\r\ni'm going to try figure out downloads/imports for other weight metrics (bmi, fat %, bone mass, etc), but need to do some reading on python and garmin's api (it's a bit above my paygrade lol)\r\nthanks for a great project!\r\n"}}
{"actor":{"display_login":"dalepharo"}}