I am using the Pandas library in Python with the Spyder application to import data from a SQL server. The import requires the following construct:
conn=pyodbc.connect('Driver=SQL Server;'
'Server=WB-SB-SQL-3,1542;'
'Database=WQI;'
'Trusted_Connection=yes;')
Finding2021=pd.read_sql_query(' SELECT'
' ID, '
' SYSTEM_NO, '
' SOURCE_NO, '
' SAMP_DATETIME, '
' STORE_NUM '
' FROM WQI.DBO.Finding '
' WHERE SAMP_DATE >= \'20110101\''
,conn)
I am adding the single quote and space to both sides of each line of the embedded SQL script, manually (see below).
'
Is there a way to add the single quote and space in bulk--let's say I have a 100-line SQL script--I don't want to have to type the single quotes 200 times. I know I could use Excel to concatenate the strings, but I was wondering if there's a built-in command using the Spyder application. Some programs like SSMS allow you to comment or uncomment blocks of code with a single click for example.