{"action":"reopened","issue":{"url":"https://api.github.com/repos/jeff1evesque/machine-learning/issues/1250","labels_url":"https://api.github.com/repos/jeff1evesque/machine-learning/issues/1250/labels{/name}","comments_url":"https://api.github.com/repos/jeff1evesque/machine-learning/issues/1250/comments","events_url":"https://api.github.com/repos/jeff1evesque/machine-learning/issues/1250/events","html_url":"https://github.com/jeff1evesque/machine-learning/issues/1250","id":56144081,"number":1250,"title":"Create 'db_query.py'","user":{"login":"jeff1evesque","id":2907085,"avatar_url":"https://avatars.githubusercontent.com/u/2907085?v=3","gravatar_id":"","url":"https://api.github.com/users/jeff1evesque","html_url":"https://github.com/jeff1evesque","followers_url":"https://api.github.com/users/jeff1evesque/followers","following_url":"https://api.github.com/users/jeff1evesque/following{/other_user}","gists_url":"https://api.github.com/users/jeff1evesque/gists{/gist_id}","starred_url":"https://api.github.com/users/jeff1evesque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeff1evesque/subscriptions","organizations_url":"https://api.github.com/users/jeff1evesque/orgs","repos_url":"https://api.github.com/users/jeff1evesque/repos","events_url":"https://api.github.com/users/jeff1evesque/events{/privacy}","received_events_url":"https://api.github.com/users/jeff1evesque/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-31T23:25:01Z","updated_at":"2015-02-02T21:46:31Z","closed_at":null,"body":"We will create `db_query.py`, which will be similar to #1243.  However, for the time being this file will simply be *imported* into each `database/data_xxx.py` file(s).  Specifically, this class will restructure the current [`data_saver.py`](https://github.com/jeff1evesque/machine-learning/blob/6c01b2720a9c3435710f1dd3ae848e3db43473b6/package/database/data_saver.py), into three imported class methods:\r\n\r\n## Start Connection\r\n\r\n```python\r\n    def sql_connect(self):\r\n      try:\r\n        self.conn   = DB.connect( host=self.db_settings.get_db_host(), user=self.db_settings.get_db_username(), passwd=self.db_settings.get_db_password() )\r\n        self.cursor = self.conn.cursor()\r\n      except DB.error, error:\r\n        self.list_error.append(error)\r\n        return { 'status': Frue, 'error': self.list_error, 'id': rowid }\r\n```\r\n\r\n## SQL Command\r\n\r\n```python\r\n    def sql_command(self, sql, args=None):\r\n      try:\r\n        self.cursor.execute( sql, args )\r\n      except DB.error, error:\r\n        self.conn.rollback()\r\n        self.list_error.append(error)\r\n        return { 'status': False, 'error': self.list_error, 'id': rowid }\r\n```\r\n\r\n**Note:** `args` should be a `list` object.\r\n\r\n## End Connection\r\n\r\n```python\r\n    def sql_disconnect(self):\r\n      try:\r\n        if self.conn:\r\n          rowid = self.cursor.lastrowid\r\n          self.conn.close()\r\n          return { 'status': True, 'error': None, 'id': rowid }\r\n      except DB.error, error:\r\n        self.list_error.append(error)\r\n        return { 'status': False, 'error': self.list_error, 'id': rowid }\r\n```"}}