title: SQL CE connection with Python
body: <p>Problem Statement: Extract data stored in the .sdf file to python.
  System config: Win 10 Pro 64-bit, python 3.5.2-64 bit, adodbapi library, SQL CE 3.5</p>
  
  <p>I am fairly new to programming and I have picked up Python as my first language to learn. Currently, I have hit a wall in process of connecting a SQL CE 3.5 .sdf file. </p>
  
  <p>I have used the adodbapi library. I have searched the web extensively over the past week to find a solution to this problem and to make sure that my connection string is correct. I have tried multiple options/solutions provided on stack overflow and <a href="https://www.connectionstrings.com/microsoft-sqlserver-ce-oledb-3-5/" rel="nofollow noreferrer">https://www.connectionstrings.com/microsoft-sqlserver-ce-oledb-3-5/</a>. </p>
  
  <p>Code:</p>
  
  <pre><code>import adodbapi
  
  cons_str = "Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.5;" \
             "Data Source=D:\Work\Programming\Python\SQL_DataTransfer\LF.sdf;"\
             "Persist Security Info=False;" \
             "SSCE:Max Database Size=4091"
  
  connection = adodbapi.connect(cons_str)
  print(connection)
  </code></pre>
  
  <p>Error Message:</p>
  
  <p>Traceback (most recent call last):</p>
  
  <blockquote>
    <p>File "D:\Work\Programs\Python35.virtualenvs\sql_output\lib\site-packages\adodbapi\adodbapi.py", line 93, in make_COM_connecter
        c = Dispatch('ADODB.Connection') #connect <em>after</em> CoIninialize v2.1.1 adamvan
    NameError: name 'Dispatch' is not defined</p>
  </blockquote>
  
  <p>During handling of the above exception, another exception occurred:</p>
  
  <p>Traceback (most recent call last):</p>
  
  <blockquote>
    <p>File "D:\Work\Programs\Python35.virtualenvs\sql_output\lib\site-packages\adodbapi\adodbapi.py", line 112, in connect
        co.connect(kwargs)
      File "D:\Work\Programs\Python35.virtualenvs\sql_output\lib\site-packages\adodbapi\adodbapi.py", line 269, in connect
        self.connector = connection_maker()
      File "D:\Work\Programs\Python35.virtualenvs\sql_output\lib\site-packages\adodbapi\adodbapi.py", line 95, in make_COM_connecter
        raise api.InterfaceError ("Windows COM Error: Dispatch('ADODB.Connection') failed.")
    adodbapi.apibase.InterfaceError: Windows COM Error: Dispatch('ADODB.Connection') failed.</p>
  </blockquote>
  
  <p>During handling of the above exception, another exception occurred:</p>
  
  <p>Traceback (most recent call last):</p>
  
  <blockquote>
    <p>File "D:/Work/Programming/Python/SQL_DataTransfer/SQL_CE_reportDB.py", line 8, in 
        connection = adodbapi.connect(cons_str)
      File "D:\Work\Programs\Python35.virtualenvs\sql_output\lib\site-packages\adodbapi\adodbapi.py", line 116, in connect
        raise api.OperationalError(e, message)
    adodbapi.apibase.OperationalError: (InterfaceError("Windows COM Error: Dispatch('ADODB.Connection') failed.",), 'Error opening connection to "Provoider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.5;Data Source=D:\Work\Programming\Python\SQL_DataTransfer\LF.sdf;Persist Security Info=False;SSCE:Max Database Size=4091"')</p>
  </blockquote>
  
  <p>At this point any help is much appreciated.</p>
  
  <p>Thank you,
  Sincerely,
  JD.</p>