Skip to content

Commit dd9d4c4

Browse files
authored
Merge pull request #21 from kdschlosser/master
Changes handling of psycopg2 as a requirement
2 parents a8e3832 + ae6d33d commit dd9d4c4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

gts/main.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from collections import OrderedDict
77
import datetime
88
import getpass
9-
import psycopg2
109
import requests
1110

1211

@@ -239,6 +238,15 @@ def store_db(db_config={}, repo='', json_response='', response_type=''):
239238
:param json_response: json - the json input
240239
:param response_type: str - 'views', 'clones', ''
241240
"""
241+
242+
try:
243+
import psycopg2
244+
except:
245+
import sys
246+
sys.stderr.write('The psycopg2 library is required to use database features.\n')
247+
sys.stderr.flush()
248+
sys.exit(1)
249+
242250
# Connect to database
243251
conn = psycopg2.connect(host=db_config['host'], port=db_config['port'], user=db_config['user'], password=db_config['password'], dbname=db_config['dbname'])
244252
conn.autocommit = True

setup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ def run(self):
5959
install_requires=[
6060
'requests'
6161
],
62+
extras_require = {
63+
'sql': ["psycopg2"]
64+
}
6265
classifiers=[
6366
'Intended Audience :: Developers',
6467
],
6568
cmdclass={
6669
'publish': PublishCommand,
6770
}
68-
)
71+
)

0 commit comments

Comments
 (0)