Created
September 14, 2014 23:32
-
-
Save tinybike/7700762729daed8c786a to your computer and use it in GitHub Desktop.
connect julia to mssql using the magic of pycall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# connect julia to mssql using the magic of pycall | |
# @author Jack Peterson (jack@tinybike.net) | |
using PyCall | |
@pyimport pymssql | |
# Connect to MSSQL Server | |
conn = pymssql.connect(server="SERVER:PORT", | |
user="USER", | |
password="PASSWORD", | |
database="DATABASE") | |
# Create a database cursor | |
cursor = conn[:cursor]() | |
# Replace this nonsense with your own query :) | |
query = "SELECT TOP 25 * | |
FROM FSDBDATA.dbo.MS04311 | |
WHERE sitecode LIKE 'PRIMET' | |
ORDER BY DATE_TIME DESC" | |
# Execute the query | |
cursor[:execute](query) | |
# Go through the results row-by-row and print them out. | |
for row in cursor | |
println(row) | |
end | |
cursor[:close]() | |
conn[:close]() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment