title: How to connect to a protected Sqlite3 database with Python
body: <p>I created a <code>SQLite3</code> database and protected it with a password ("test") thanks to the application <code>DB browser for SQLite</code>.
  In order to connect to my database via <code>Python</code>, I need to provide the password but I can't figure out how to do that. I tried the following code:</p>
  
  <pre><code>conn=sqlite3.connect("mydatabase.db", Password="test")
  cur=conn.cursor()
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>My <code>SQLite3</code> database has been encrypted with <code>SQLCipher</code> (see image).
  <a href="https://i.stack.imgur.com/kSXYf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kSXYf.png" alt="enter image description here"></a>
  If I run the following code:</p>
  
  <pre><code>conn=sqlite3.connect("mydatabase.db")
  cur=conn.cursor()
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>sqlite3.DatabaseError: file is encrypted or is not a database
  </code></pre>
  
  <p>How can I pass the password in order to connect with my <code>db</code> via Python?</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Here a brief summary of what I try to achieve. I am developing an application with <code>Python 3</code> requiring a pre-populated database but this database needs to be protected with a password.
  After extensive research, it seems complicated to connect an encrypted <code>SQLite3</code> database via <code>Python 3</code>. A library calls <code>pysqlcipher</code> exists but only for Python 2.7. My next question will be maybe too broadly and I apology in advance. Is there another portable database that exists allowing me to protect it with a password and still get access to Python?
  Another idea that I have in mind in order to troubleshoot my problem is to use the <code>zipfile</code> library. This <a href="https://www.sqlite.org/zipfile.html" rel="nofollow noreferrer">link</a> mentions that the <code>zipfile</code> module does not support encryption but it’s not clear if encryption refers to the <code>SQLite3</code> database or to the zip file. The idea would be to zip my unprotected <code>DB</code> into a protected zip file as it seems I can do that (<a href="https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile.setpassword" rel="nofollow noreferrer">link</a>).
  The goal of this edit is to get new ideas on how to solve my problem. Thanks</p>