diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index f2afe69..69e4f34 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -17,8 +17,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.11.4 - - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: ./Tools/mssql-proxy/odbc-driver-installer.sh + - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.linux.spec working-directory: Tools/mssql-proxy - id: name diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 095879a..59b4d0c 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -17,9 +17,7 @@ jobs: run: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release - HOMEBREW_SANDBOX=1 HOMEBREW_ACCEPT_EULA=Y brew install unixodbc msodbcsql18 tree - tree /opt/homebrew/Cellar/msodbcsql18/ - cat /opt/homebrew/Cellar/msodbcsql18/18.4.1.1/odbcinst.ini + HOMEBREW_SANDBOX=1 HOMEBREW_ACCEPT_EULA=Y brew install unixodbc msodbcsql18 - run: pip install -r Tools/mssql-proxy/requirements.txt pyinstaller - run: pyinstaller mssql-proxy.mac.spec diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index dde51e8..0c54f70 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -17,23 +17,23 @@ jobs: uses: ./.github/workflows/publish.yml if: github.ref_type == 'tag' -# build-linux: -# uses: ./.github/workflows/build-linux.yml + build-linux: + uses: ./.github/workflows/build-linux.yml -# build-windows: -# uses: ./.github/workflows/build-windows.yml + build-windows: + uses: ./.github/workflows/build-windows.yml build-macos: uses: ./.github/workflows/build-macos.yml -# build-publish-docker: -# uses: ./.github/workflows/build-publish-docker.yml -# needs: [publish, build-linux, build-windows, build-macos] + build-publish-docker: + uses: ./.github/workflows/build-publish-docker.yml + needs: [publish, build-linux, build-windows, build-macos] release: runs-on: ubuntu-latest if: github.ref_type == 'tag' -# needs: [build-publish-docker] + needs: [build-publish-docker] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/Frontend/src/app/downloads/downloads.component.html b/Frontend/src/app/downloads/downloads.component.html index c44a4a6..e0ad905 100644 --- a/Frontend/src/app/downloads/downloads.component.html +++ b/Frontend/src/app/downloads/downloads.component.html @@ -14,7 +14,7 @@

MSSQl proxy server

Windows Linux - AMD64 Linux - ARM64 - Mac OS + Mac OS Python Source Code diff --git a/Tools/mssql-proxy/mssql-proxy.py b/Tools/mssql-proxy/mssql-proxy.py index 33b6b29..f01ba56 100644 --- a/Tools/mssql-proxy/mssql-proxy.py +++ b/Tools/mssql-proxy/mssql-proxy.py @@ -6,7 +6,7 @@ from pydantic import BaseModel import uvicorn from colorama import Fore, Style, init -import sys +import sys, os # Initialize colorama init(autoreset=True) @@ -73,20 +73,35 @@ def log_query(index, query): endpoint_text = f"{Fore.GREEN}execute-query{Style.RESET_ALL}" print(f"{index_text} {endpoint_text}: Executed query: {query}") +def find_file_path(file_name): + base_path = sys._MEIPASS + for root, _, files in os.walk(f"{base_path}/drivers"): + if file_name in files: + return os.path.join(root, file_name) + raise f"{file_name} NotFound." + +def find_odbc_driver_path(): + try: + with open(find_file_path("odbcinst.ini"), 'r') as file: + for line in file: + line = line.strip() + if line.startswith("Driver="): + driver_name = line.split("/")[-1].strip() + break + + return find_file_path(driver_name) + except: + print("Could not fild odbc driver internally...") + return "{SQL Server}" + # Establish a database connection and return a unique connection ID @app.post("/connect") async def connect(request: ConnectRequest): global connection_index_counter try: # Attempt to connect to the database - try: - connection = pyodbc.connect(f"Driver={{SQL Server}};Server={request.server};UID={request.username};PWD={request.password};", timeout=5) - except: - try: - base_path = sys._MEIPASS - connection = pyodbc.connect(f"Driver={base_path}/drivers/msodbcsql18/lib64/libmsodbcsql-18.4.so.1.1;Server={request.server};UID={request.username};PWD={request.password};", timeout=5) - except: - raise + driver_path = find_odbc_driver_path() + connection = pyodbc.connect(f"Driver={driver_path};Server={request.server};UID={request.username};PWD={request.password};", timeout=5) # Generate a unique ID and index for the connection connection_id = str(uuid.uuid4())