Python Forum
Reading SQL scripts from excel file and run it using python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading SQL scripts from excel file and run it using python
#3
Thanks Ibreedan

Now python code is working fine. But 2 problem's
1) I am not getting column header name when I run SQL scripts through Python.
2) How to auto increment next row in excel file. E.g If my Cell value is (0,0) and if I want to read the SQL script available in Cell value (1,0) . How to do it ?


import xlrd
import pyodbc 
conn = pyodbc.connect('Driver={SQL Server};'
                      'Server=Servername'
                      'Database=PythonSQL;'
                      'Trusted_Connection=yes;')
file_location= "E:/Python Automation/file.xls"
workbook =xlrd.open_workbook(file_location)
sheet =workbook.sheet_by_index(0)
query=sheet.cell_value(0,0)
cursor = conn.cursor()
cursor.execute(query)
for row in cursor:
    print(row)
Reply


Messages In This Thread
RE: Reading SQL scripts from excel file and run it using python - by saravanatn - Aug-23-2020, 04:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python openyxl not updating Excel file MrBean12 1 370 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Copy Paste excel files based on the first letters of the file name Viento 2 476 Feb-07-2024, 12:24 PM
Last Post: Viento
Sad problems with reading csv file. MassiJames 3 683 Nov-16-2023, 03:41 PM
Last Post: snippsat
  Search Excel File with a list of values huzzug 4 1,289 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Updating sharepoint excel file odd results cubangt 1 889 Nov-03-2023, 05:13 PM
Last Post: noisefloor
  trouble reading string/module from excel as a list popular_dog 0 440 Oct-04-2023, 01:07 PM
Last Post: popular_dog
  Reading a file name fron a folder on my desktop Fiona 4 943 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  Trying to us python.exe from our network to run scripts cubangt 3 897 Aug-17-2023, 07:53 PM
Last Post: deanhystad
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,137 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Save and Close Excel File avd88 0 3,123 Feb-20-2023, 07:19 PM
Last Post: avd88

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020