Posts: 1
Joined: Tue Aug 14, 2018 2:54 pm

How to query a MS SQL DB with Pi ?

Tue Aug 14, 2018 3:02 pm

Hello, I am wanting to see how we can query a Microsoft SQL Database using a Raspberry Pi.

We have a remote MS SQL server, that we do not have a direct connection to. We have a Raspberry Pi on the same remote network, and we are wanting to be able to run a simple query on the PI to check if the MS SQL Server is online / loading data.

How can I run something as basic as select SERVERPROPERTY('MachineName') or Select top 10 from [Accounts] and get the results either on command line or gui?

User avatar
Posts: 34561
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: How to query a MS SQL DB with Pi ?

Tue Aug 14, 2018 7:49 pm

Try this Google search: "raspberry unixodbc mssql site:raspberrypi.org".
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

User avatar
Posts: 2
Joined: Tue Jul 03, 2018 5:57 pm
Contact: Website Facebook Twitter YouTube

Re: How to query a MS SQL DB with Pi ?

Tue Aug 14, 2018 11:01 pm

What Language are you using ?

If you are wanting to install mysql and use with php here ya go

quick and easy way... Install ampps its a aio.

Or you can Install Myql

Code: Select all

sudo apt-get install mysql-server
sudo apt-get install php5-fpm php5-mysql
Or my FAV using python with it

Code: Select all

import mysql.connector

mydb = mysql.connector.connect(

mycursor = mydb.cursor()

mycursor.execute("SELECT * FROM customers")

myresult = mycursor.fetchall()

for x in myresult:
Remember You Are Amazing!

looking for a person that enjoys speaking and loves tech.

Return to “Beginners”