mattn01 commited on
Commit
6ed8df0
·
verified ·
1 Parent(s): 75129a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -4,6 +4,7 @@ from sqlalchemy import create_engine, text
4
  # Fixed SQL Server details
5
  SERVER = "indsr-foundry.database.windows.net"
6
  DATABASE = "foundry_db_monarch"
 
7
 
8
  st.set_page_config(page_title="SQL Server Connection Test", layout="centered")
9
 
@@ -14,9 +15,12 @@ username = st.text_input("Database Username", placeholder="Enter your username")
14
  password = st.text_input("Database Password", type="password", placeholder="Enter your password")
15
 
16
  def test_connection(username, password):
17
- """Attempts to connect to the SQL Server using SQLAlchemy + pytds."""
18
  try:
19
- conn_str = f"mssql+pytds://{username}:{password}@{SERVER}/{DATABASE}"
 
 
 
20
  engine = create_engine(conn_str, pool_pre_ping=True)
21
 
22
  with engine.connect() as connection:
 
4
  # Fixed SQL Server details
5
  SERVER = "indsr-foundry.database.windows.net"
6
  DATABASE = "foundry_db_monarch"
7
+ DRIVER = "ODBC Driver 17 for SQL Server" # Make sure this matches the installed driver
8
 
9
  st.set_page_config(page_title="SQL Server Connection Test", layout="centered")
10
 
 
15
  password = st.text_input("Database Password", type="password", placeholder="Enter your password")
16
 
17
  def test_connection(username, password):
18
+ """Attempts to connect to the SQL Server using SQLAlchemy + pyodbc."""
19
  try:
20
+ conn_str = (
21
+ f"mssql+pyodbc://{username}:{password}@{SERVER}/{DATABASE}?"
22
+ f"driver={DRIVER}&Encrypt=yes&TrustServerCertificate=no"
23
+ )
24
  engine = create_engine(conn_str, pool_pre_ping=True)
25
 
26
  with engine.connect() as connection: