Data Analysis: using Python and SMS API to broadcast SQL data

emmy adigun
2 min readNov 30, 2020
freepik.com

During the lockdown, a senior colleague shared his idea with me on broadcasting analyzed transaction data to relevant stakeholders daily. At 8 am in the morning, stakeholders’ phones are buzzed with a breakdown of the previous day’s transaction data on one of our products which enables them to make an informed decision about the product. This application seems to be one of the less challenging data projects I have worked on. With just a few lines of python code, the application was ready.

Start Programming

Import the libraries and packages

Connect to SQL server

The connection below works for both SQL management studio and Azure Data studio. The former is for windows while the latter is for Mac.

Run query

The cursor.execute function can be used to retrieve a result from a query against an SQL database. This function accepts a query and returns a result set, which can be iterated over with the use of cursor.fetchone()

SMS API connection

The broadcast message can be sent to a single mobile number or as bulk

Confirm request Authentication and Run your application

The post() method sends a POST request to the specified URL

Sample of the SMS message

Conclusion

That’s all folks!!

--

--