How to replace Cursor in SQL Server?

SQL/Python Program Help?

  • Hey all, I am working on a Python SQL program for school to search a query and then print results out on screen and then to a file, does this look good or what needs work? Thanks: # Connect to the SQL DB conn = adodbapi.connect("Provider=SQLDB ;SERVER= x.x.x.x ;User Id=user;Password=pass;DATABASE=db database;") curs = conn.cursor() # Execute SQL query test_file.sql" query = 'test_file' curs.execute('test_file') results = curs.fetchall() print results results = open('test_file.txt','w') print>>results,'test_file' results.close() conn.close()

  • Answer:

    curs.execute('test_file') --> that's no SQL! try a valid sql statement to see if your db connection works, maybe: curs.execute("SELECT 'hello world!'") and probably you should open the file and execute each sql statement within it from python, that would make more sense...

BDex at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.