Spaces:
Sleeping
Sleeping
jonathanjordan21
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -11,18 +11,27 @@ from sentence_transformers import SentenceTransformer
|
|
11 |
from sentence_transformers.util import cos_sim
|
12 |
from sentence_transformers import CrossEncoder
|
13 |
|
14 |
-
import mysql.connector
|
|
|
15 |
|
16 |
db_user = os.environ["DB_NAME"]
|
17 |
|
18 |
-
mydb = mysql.connector.connect(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
host=os.environ["DB_HOST"],
|
20 |
user=os.environ["DB_USER"],
|
21 |
port=os.environ["DB_PORT"],
|
22 |
password=os.environ["DB_PASSWORD"]
|
23 |
)
|
24 |
|
25 |
-
|
|
|
26 |
df_bobot = pd.read_sql(f"SELECT * FROM {db_user}.bobot", mydb)
|
27 |
df_bobot['BOBOT'] = [float(x.replace(",",".")) for x in df_bobot['BOBOT']]#.astype(float)
|
28 |
df_bobot["JENIS_KENDARAAN"] = [x[:-2] + x[-1] if x[-2] == "." else x for x in df_bobot["JENIS_KENDARAAN"]]
|
|
|
11 |
from sentence_transformers.util import cos_sim
|
12 |
from sentence_transformers import CrossEncoder
|
13 |
|
14 |
+
# import mysql.connector
|
15 |
+
import psycopg2
|
16 |
|
17 |
db_user = os.environ["DB_NAME"]
|
18 |
|
19 |
+
# mydb = mysql.connector.connect(
|
20 |
+
# host=os.environ["DB_HOST"],
|
21 |
+
# user=os.environ["DB_USER"],
|
22 |
+
# port=os.environ["DB_PORT"],
|
23 |
+
# password=os.environ["DB_PASSWORD"]
|
24 |
+
# )
|
25 |
+
|
26 |
+
mydb = psycopg2.connect(
|
27 |
host=os.environ["DB_HOST"],
|
28 |
user=os.environ["DB_USER"],
|
29 |
port=os.environ["DB_PORT"],
|
30 |
password=os.environ["DB_PASSWORD"]
|
31 |
)
|
32 |
|
33 |
+
|
34 |
+
df_sample = pd.read_sql(f"SELECT * FROM {db_user}.sample", mydb)
|
35 |
df_bobot = pd.read_sql(f"SELECT * FROM {db_user}.bobot", mydb)
|
36 |
df_bobot['BOBOT'] = [float(x.replace(",",".")) for x in df_bobot['BOBOT']]#.astype(float)
|
37 |
df_bobot["JENIS_KENDARAAN"] = [x[:-2] + x[-1] if x[-2] == "." else x for x in df_bobot["JENIS_KENDARAAN"]]
|