search.py
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask import jsonify, Response
import json
import cx_Oracle
import os
from config.key import DATABASE_ID, DATABASE_PW
from config.URLs import DATABASE_URL
def search(insta_id):
connection = cx_Oracle.connect(DATABASE_ID, DATABASE_PW, DATABASE_URL)
cursor = connection.cursor()
cursor.execute(f"""
select * from users where user_id=\'{insta_id}\'
""")
exist_user = cursor.fetchall()
print(exist_user)
cursor.execute(f"""
select * from followers where user_id=\'{insta_id}\'
""")
exist_followers = cursor.fetchall()
print(exist_followers)
exist_info = ()
if len(exist_user) > 0:
exist_info = {
"user": exist_user[0],
"follower": exist_followers
}
print(exist_info)
cursor.close()
return Response(json.dumps(exist_info), mimetype='application/json')
if __name__ == '__main__':
os.putenv('NLS_LANG', '.UTF8')
cx_Oracle.init_oracle_client(lib_dir="/Users/choewonseog/Downloads/instantclient_19_8")
print(search('__re.mind.er__').data)