Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DB Connections, Thread based processing, Other updates..
- Loading branch information
1 parent
949eda5
commit f155080
Showing
7 changed files
with
461 additions
and
145 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
# Credentials you get from registering a new application | ||
client_id = os.environ.get("CLIENT_ID") | ||
client_secret = os.environ.get("CLIENT_SECRET") | ||
#redirect_uri = "https://nimpf.akimbo.com" | ||
# OAuth endpoints given in the Google API documentation | ||
authorization_base_url = "https://accounts.google.com/o/oauth2/v2/auth" | ||
token_url = "https://www.googleapis.com/oauth2/v4/token" | ||
refresh_url = token_url | ||
scope = [ | ||
"https://www.googleapis.com/auth/userinfo.email", | ||
"https://www.googleapis.com/auth/userinfo.profile", | ||
"openid", | ||
"https://www.googleapis.com/auth/gmail.settings.basic", | ||
"https://www.googleapis.com/auth/gmail.modify", | ||
] | ||
whitelist = ['sethgodin.com', 'adobe.com', 'alxpck.com', 'altmba.com'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import psycopg2, os | ||
import psycopg2.extras | ||
|
||
class Db(): | ||
def __init__(self): | ||
self._conn_str = os.environ.get('DATABASE_URL') | ||
|
||
def query(self, sql, data=None, verbose=False): | ||
conn = psycopg2.connect(self._conn_str) | ||
cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor) | ||
if verbose == True: | ||
print(cur.mogrify(sql, data)) | ||
cur.execute(sql, data) | ||
conn.commit() | ||
|
||
if cur.description is not None: | ||
results = cur.fetchall() | ||
|
||
cur.close() | ||
conn.close() | ||
|
||
if cur.description is not None: | ||
if len(results) == 1: | ||
return results[0] | ||
elif len(results) == 0: | ||
return None | ||
else: | ||
return results | ||
|
||
|
||
|
||
|
||
# UNIT TESTS | ||
if __name__=='__main__': | ||
db = Db() | ||
users = db.query('select * from participant;') | ||
print(users) | ||
#users = db.query('insert into participant (email) values (%s) returning email;', ['shandgp@clarkson.edu']) | ||
#print(users) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,22 @@ | ||
anytree==2.7.1 | ||
APScheduler==3.5.0 | ||
asn1crypto==0.24.0 | ||
Authlib==0.10 | ||
certifi==2017.7.27.1 | ||
cffi==1.12.2 | ||
certifi==2019.9.11 | ||
cffi==1.13.0 | ||
chardet==3.0.4 | ||
click==6.7 | ||
cryptography==2.6.1 | ||
fastcache==1.1.0 | ||
Flask==0.12.2 | ||
Click==7.0 | ||
cryptography==2.8 | ||
Flask==1.1.1 | ||
Flask-SSLify==0.1.5 | ||
googlemaps==3.1.3 | ||
gspread==3.1.0 | ||
gunicorn==19.7.1 | ||
httplib2==0.14.0 | ||
idna==2.6 | ||
itsdangerous==0.24 | ||
Jinja2==2.9.6 | ||
MarkupSafe==1.0 | ||
newrelic==5.0.2.126 | ||
numpy==1.16.4 | ||
oauth2client==4.1.3 | ||
idna==2.8 | ||
itsdangerous==1.1.0 | ||
Jinja2==2.10.3 | ||
MarkupSafe==1.1.1 | ||
oauthlib==3.1.0 | ||
pandas==0.25.1 | ||
phonenumbers==8.9.12 | ||
psycopg2==2.7.3.2 | ||
pyasn1==0.4.7 | ||
pyasn1-modules==0.2.6 | ||
psycopg2==2.8.3 | ||
pycparser==2.19 | ||
PyMySQL==0.9.3 | ||
pyOpenSSL==19.0.0 | ||
python-dateutil==2.8.0 | ||
pytz==2017.3 | ||
redis==2.10.6 | ||
redis==3.3.11 | ||
requests==2.22.0 | ||
requests-oauthlib==1.2.0 | ||
rq==0.12.0 | ||
rsa==4.0 | ||
six==1.11.0 | ||
stripe==2.29.3 | ||
toml==0.9.6 | ||
tzlocal==1.5.1 | ||
untangle==1.1.1 | ||
urllib3==1.22 | ||
Werkzeug==0.12.2 | ||
rq==1.1.0 | ||
six==1.12.0 | ||
urllib3==1.25.6 | ||
Werkzeug==0.16.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.