How to use SQLCMD in ARM64 architecture?

Pritam Chanda 45 Reputation points
2024-06-20T10:56:41.71+00:00

I am using NVIDIA Jetson Orin nano board (which is based on ARM64 architecture) to as an IoT Edge device to deploy Azure Edge modules from Azure marketplace.
I have deployed the temperature sensor and SQL Edge module modules inside the board, and they are running perfectly.

But when I am going inside the SQL Edge container to connect using sqlcmd (using https://learn.microsoft.com/en-us/azure/azure-sql-edge/connect) I can't find it:

mssql@e0f0035b988c:/$ /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourPassword>'
bash: /opt/mssql-tools/bin/sqlcmd: No such file or directory

So, I searched the official documentation and found out that SQL client tools are not available on ARM64 platform.
So is there a solution to how we can use sqlcmd?

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
576 questions
Azure SQL Edge
Azure SQL Edge
An Azure service that provides a small-footprint, edge-optimized data engine with built-in artificial intelligence. Previously known as Azure SQL Database Edge.
48 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 12,011 Reputation points
    2024-06-20T15:02:45.4666667+00:00

    Hello Pritam Chanda,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    Problem

    I understand that you are having challenges to connect your ARM64 platform to SQL Edge container using sqlcmd tool.

    Solution

    The sqlcmd tool is indeed not available for ARM64 platforms, which poses a challenge when you need to interact with SQL Edge on such devices. However, there are alternative methods to connect to and manage your SQL Edge instance on an ARM64 platform like the NVIDIA Jetson Orin Nano board.

    The simplest way, you can run sqlcmd from another machine (such as a Windows, Linux, or macOS machine) that is not ARM64. This machine can be on the same network as your Jetson Orin Nano board. You would connect remotely to your SQL Edge instance running on the ARM64 device.

    Using the typical example of this command: sqlcmd -S <Jetson_IP_Address>,<Port> -U SA -P '<YourPassword>'

    You can run SQL queries directly from within the Docker container using the docker exec command. This method involves running SQL scripts or queries directly inside the container by using this example code: docker exec -it <container_name> /bin/bash -c "echo 'SELECT * FROM your_table' | /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourPassword>'"

    Most common for IoT Developers is to use programming languages like Python with appropriate libraries (e.g., pyodbc or pymssql) to connect to your SQL Edge instance and run queries. This can be done either from another machine or directly on the ARM64 device if the libraries support ARM64.

    An example of your Python script will be similar to:

    import pyodbc
    connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=<Jetson_IP_Address>,<Port>;UID=SA;PWD=<YourPassword>')
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM your_table")
    for row in cursor:
        print(row)
    

    Also, if SQL Edge supports REST API, you can use HTTP requests to interact with your database. This method is not common but can be useful in certain scenarios.

    Lastly, you can use graphical tools like Azure Data Studio or SQL Server Management Studio (SSMS) on another machine to connect to your SQL Edge instance. These tools provide a rich interface for managing SQL databases.

    References

    For more reading, step-by-steps and information for the above alternatives, kindly use the below links and the additional resources available by the right side of this page.

    Source: Use SQLCMD from Another Machine. Accessed, 6/20/2024.

    Source: Use Azure Data Studio or SQL Server Management Studio (SSMS). Accessed, 6/20/2024.

    Source: Use Docker Exec to Run SQL Queries. Accessed, 6/20/2024.

    Source: Using Python or Other Programming Languages. Accessed, 6/20/2024.

    Source: Azure SQL Edge Documentation. Accessed, 6/20/2024.

    Accept Answer

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam

    0 comments No comments

  2. Bruce (SqlWork.com) 66,706 Reputation points
    2024-06-20T20:35:19.3533333+00:00

    while Azure SQL Edge (like SqlServer) no longer supports arm64 (even Windows OS), this is not true for sqlcmd. there is a sqlcmd written in go that is supported on arm64:

    https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-utility?view=sql-server-ver16&tabs=go%2Clinux&pivots=cs1-bash


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.