Skip to content

Commit de69559

Browse files
author
root
committed
Fixed DB namespace issue
1 parent ee75235 commit de69559

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

api/Comment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections import defaultdict
44
import Parameters
55
from Helpers import *
6-
6+
import DBFunctions
77

88
class search:
99
params = None
@@ -30,7 +30,7 @@ def getIds(self,ids):
3030
if id[:3] == "t1_":
3131
id = id[3:]
3232
ids_to_get_from_db.append(base36decode(id))
33-
rows = pgdb.execute("SELECT * FROM comment WHERE (json->>'id')::bigint IN %s LIMIT 5000",tuple(ids_to_get_from_db))
33+
rows = DBFunctions.pgdb.execute("SELECT * FROM comment WHERE (json->>'id')::bigint IN %s LIMIT 5000",tuple(ids_to_get_from_db))
3434
results = []
3535
data = {}
3636
if rows:

api/DBFunctions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ def execute(self,sql,params):
3434
self.connect()
3535
except:
3636
raise
37+
38+
pgdb = pgdb()
39+

api/Helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections import defaultdict
22
import requests
33
import json
4+
import DBFunctions
45

56
def LooksLikeInt(s):
67
try:
@@ -55,7 +56,7 @@ def getSubmissionsFromPg(ids):
5556
if not isinstance(ids, (list, tuple)):
5657
ids = [ids]
5758
ids_to_get_from_db = []
58-
rows = pgdb.execute("SELECT * FROM submission WHERE (json->>'id')::int IN %s LIMIT 5000",tuple(ids))
59+
rows = DBFunctions.pgdb.execute("SELECT * FROM submission WHERE (json->>'id')::int IN %s LIMIT 5000",tuple(ids))
5960
results = {}
6061
data = {}
6162
if rows:

api/api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def on_get(self, req, resp, submission_id):
7777
if submission_id[:3] == 't3_':
7878
submission_id = submission_id[3:]
7979
submission_id = base36decode(submission_id)
80-
rows = pgdb.execute("SELECT (json->>'id')::bigint comment_id FROM comment WHERE (json->>'link_id')::int = %s ORDER BY comment_id ASC LIMIT 50000",submission_id)
80+
rows = DBFunctions.pgdb.execute("SELECT (json->>'id')::bigint comment_id FROM comment WHERE (json->>'link_id')::int = %s ORDER BY comment_id ASC LIMIT 50000",submission_id)
8181
results = []
8282
data = {}
8383
if rows:
@@ -96,7 +96,6 @@ def database_connection():
9696
config.read ('credentials.ini')
9797
DB_PASSWORD = config.get('database','password')
9898
DB_USER = config.get('database','user')
99-
pgdb = DBFunctions.pgdb()
10099
r = redis.StrictRedis(host='localhost', port=6379, db=1)
101100
api = falcon.API()
102101
api.add_route('/reddit/search', Comment.search())

0 commit comments

Comments
 (0)