Spaces:
Running
Running
Update verification.py
Browse files- verification.py +24 -17
verification.py
CHANGED
|
@@ -106,33 +106,40 @@ app.config["COHERE_API_KEY"] = os.getenv("COHERE_API_KEY", "")
|
|
| 106 |
# DB_SERVER = "pykara-sqlserver.cb60o04yk948.ap-south-1.rds.amazonaws.com,1433"
|
| 107 |
# DB_DATABASE = "AuthenticationDB1"
|
| 108 |
|
| 109 |
-
DB_SERVER = os.getenv("DB_SERVER", "
|
| 110 |
DB_DATABASE = os.getenv("DB_DATABASE", "AuthenticationDB1")
|
| 111 |
DB_DRIVER = os.getenv("DB_DRIVER", "ODBC Driver 17 for SQL Server") # 17 in your image
|
| 112 |
|
| 113 |
-
|
| 114 |
-
#
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
#
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
else:
|
| 128 |
-
# SQL auth
|
| 129 |
CONN_STR = (
|
| 130 |
f"DRIVER={{{DB_DRIVER}}};"
|
| 131 |
f"SERVER={DB_SERVER};DATABASE={DB_DATABASE};"
|
| 132 |
f"UID={os.getenv('DB_USER')};PWD={os.getenv('DB_PASSWORD')};"
|
| 133 |
-
"Encrypt=yes;TrustServerCertificate=yes"
|
| 134 |
)
|
| 135 |
|
|
|
|
|
|
|
|
|
|
| 136 |
# def get_db_connection():
|
| 137 |
# """Create a short-timeout connection. Fail clearly if secrets are missing."""
|
| 138 |
# if "Trusted_Connection=yes" not in CONN_STR:
|
|
|
|
| 106 |
# DB_SERVER = "pykara-sqlserver.cb60o04yk948.ap-south-1.rds.amazonaws.com,1433"
|
| 107 |
# DB_DATABASE = "AuthenticationDB1"
|
| 108 |
|
| 109 |
+
DB_SERVER = os.getenv("DB_SERVER", r"(localdb)\MSSQLLocalDB")
|
| 110 |
DB_DATABASE = os.getenv("DB_DATABASE", "AuthenticationDB1")
|
| 111 |
DB_DRIVER = os.getenv("DB_DRIVER", "ODBC Driver 17 for SQL Server") # 17 in your image
|
| 112 |
|
| 113 |
+
|
| 114 |
+
# Build connection string (FIXED)
|
| 115 |
+
is_local = (
|
| 116 |
+
DB_SERVER.lower().startswith("localhost")
|
| 117 |
+
or DB_SERVER.startswith(".")
|
| 118 |
+
or DB_SERVER.lower().startswith("(localdb)")
|
| 119 |
+
or "\\" in DB_SERVER
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
if is_local:
|
| 123 |
+
# Windows local / LocalDB using modern ODBC driver
|
| 124 |
+
CONN_STR = (
|
| 125 |
+
f"DRIVER={{{DB_DRIVER}}};"
|
| 126 |
+
f"SERVER={DB_SERVER};"
|
| 127 |
+
f"DATABASE={DB_DATABASE};"
|
| 128 |
+
"Trusted_Connection=yes;"
|
| 129 |
+
"TrustServerCertificate=yes;"
|
| 130 |
+
)
|
| 131 |
else:
|
| 132 |
+
# Remote SQL auth
|
| 133 |
CONN_STR = (
|
| 134 |
f"DRIVER={{{DB_DRIVER}}};"
|
| 135 |
f"SERVER={DB_SERVER};DATABASE={DB_DATABASE};"
|
| 136 |
f"UID={os.getenv('DB_USER')};PWD={os.getenv('DB_PASSWORD')};"
|
| 137 |
+
"Encrypt=yes;TrustServerCertificate=yes;"
|
| 138 |
)
|
| 139 |
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
# def get_db_connection():
|
| 144 |
# """Create a short-timeout connection. Fail clearly if secrets are missing."""
|
| 145 |
# if "Trusted_Connection=yes" not in CONN_STR:
|