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
Related Q & A:
- How do I make a python web program that is on a ubuntu server allow access to the server?Best solution by Yahoo! Answers
- How do I compile my Python program to a .jar with Jython?Best solution by Stack Overflow
- Can someone help me find a study abroad program?Best solution by Yahoo! Answers
- Is there a free service or program in Vancouver offers people with disabilities help with dating?Best solution by Yahoo! Answers
- International Baccalaureate program help?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.