title: Unable to execute Excel SQL Query from Python application
body: <p>From my Python application, I am trying to open an ADODB connection of Excel. The code is as below:</p>
  
  <pre><code># Create Connection object and connect to database.
  ado_conn = win32com.client.gencache.EnsureDispatch('ADODB.Connection')
  ado_conn.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\\Test1.xlsx; Extended Properties ='Excel 12.0 Xml;HDR=YES'";
  
  ado_conn.Open()
  
  # Now create a RecordSet object and open a table
  oRS = win32com.client.gencache.EnsureDispatch('ADODB.Recordset')
  oRS.ActiveConnection = ado_conn    # Set the recordset to connect thru oConn
  
  oRS.Open("SELECT * FROM [Orders]") 
  </code></pre>
  
  <p>When I debug the application, it throws the error:</p>
  
  <blockquote>
    <p>com_error(-2147352567, 'Exception occurred.', (0, 'Microsoft Access Database Engine', "The Microsoft Access database engine could not find the object 'Orders'. Make sure the object exists and that you spell its name and the path name correctly. If 'Orders' is not a local object, check your network connection or contact the server administrator.", None, 5003011, -2147217865), None)</p>
  </blockquote>
  
  <p>In the Excel sheet the connection string looks like this:</p>
  
  <pre><code>Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=Orders;Extended Properties=""
  </code></pre>
  
  <p>The Command Text is:</p>
  
  <pre><code>Select * from [Orders]
  </code></pre>
  
  <p>Even if the connection is there, it is throwing this error.</p>
  
  <p>How to execute the above Excel query from Python application?</p>
  
  <p><strong>Edit: Excel connection screenshot added below</strong></p>
  
  <p><a href="https://i.stack.imgur.com/riS9T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/riS9T.png" alt="enter image description here"></a></p>