0

I want to learn python, and my task is the run a sql server 2008 stored procedure via a cron job.

Can someone step through a script for me in python?

1 Answer 1

1

I am assuming you mean Microsoft's SQL server...

#! /usr/bin/python

import pymssql
con = pymssql.connect (host='xxxxx',user='xxxx',
                       password='xxxxx',database='xxxxx')
cur = con.cursor()
query = "DECLARE @id INT; EXECUTE sp_GetUserID; SELECT @id;"
cur.execute(query)
outputparameter = cur.fetchall()
con.commit()
con.close()

Taken from http://coding.derkeiler.com/Archive/Python/comp.lang.python/2008-10/msg02620.html (copyright retained)

Put that in a script and run it from cron...

Check this question too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.