diff --git a/.travis.yml b/.travis.yml index 564a56f3..f1332089 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,6 @@ services: before_script: - psql -c "CREATE DATABASE test_nbox;" -U postgres - - psql -c "CREATE USER antoo WITH PASSWORD 'antoo123';" -U postgres - - psql -c "GRANT ALL PRIVILEGES ON DATABASE test_nbox to antoo;" -U postgres script: - "python -m pytest tests/" diff --git a/README.md b/README.md index 5eca82a9..b76b42a8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Build Status](https://travis-ci.com/icodeai/nbox.svg?branch=databases_postgres)](https://travis-ci.com/icodeai/nbox) [![Coverage Status](https://coveralls.io/repos/github/icodeai/nbox/badge.svg?branch=databases_postgres)](https://coveralls.io/github/icodeai/nbox?branch=databases_postgres) - +[![Build Status](https://travis-ci.org/Joseorina/nbox.svg?branch=databases_postgres)](https://travis-ci.org/Joseorina/nbox) # Nbox ML Toolkit diff --git a/database.py b/database.py index 1606cce6..b3536a07 100644 --- a/database.py +++ b/database.py @@ -24,7 +24,7 @@ def status(self): def cursor(self): pass - # @abstractmethod + @abstractmethod def select_table(self,query): pass diff --git a/db_config.py b/db_config.py index 41972a8f..d900a722 100644 --- a/db_config.py +++ b/db_config.py @@ -45,8 +45,21 @@ def cursor(self): connection = self.connect(DATABASE_URL) cursor = connection.cursor() return cursor - - + + def select_table(self, query): + """" + Fetch and disaplay records from a database + """ + try: + connection = p.connect(DATABASE_URL) + cursor = connection.cursor() + cursor.execute(query) + rows=cursor.fetchall() + connection.close + except: + return 'failed to connect' + if __name__ == "__main__": db = PostgresConfig() - print(db.connect(DATABASE_URL)) + print(db.connect( + DATABASE_URL)) diff --git a/tests/integration/test_postgres.py b/tests/integration/test_postgres.py index 5168dec0..b4ab4dea 100644 --- a/tests/integration/test_postgres.py +++ b/tests/integration/test_postgres.py @@ -15,6 +15,16 @@ def setUp(self): def test_make_good_connection(self): - print(TEST_DATABASE_URL) self.assertNotEqual(self.postgres.connect(TEST_DATABASE_URL), - 'failed to connect to database.') + 'connected.') + def test_select_table(self): + """ + test function to select table + + Arguments: + self {[type]} -- [description] + """ + print(TEST_DATABASE_URL) + self.assertNotEqual(self.postgres.select_table(TEST_DATABASE_URL), + 'connected') + \ No newline at end of file