# Attaching databases using backwards compatibility

**URL:** <https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012>\
**Category:** SQLCipher\
**Created:** [November 2, 2019, 7:14pm UTC](https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012 "2019-11-02T19:14:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![signum-net](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/signum-net/32/2107_2.png) [@signum-net](https://discuss.zetetic.net/u/signum-net)\
**Post date:** [November 2, 2019, 7:14pm UTC](https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012/1 "2019-11-02T19:14:18Z")

</div>

I have some database created with SQLCipher version 3.  
I opened main db and attached a few other database with different keys.  
But there are some problems with attaching after upgrading SQLCipher to version4.  
Even if I use  
PRAGMA cipher\_compatibility = 3;  
after keying I can connect and work with main database, but I can not attach other database - the error code 26 is returned (SQLITE\_NOTADB - the file being opened does not appear to be an SQLite database file).  
It works with previous version of SQLCipher, but it doesn’t work now !  
Can anyone have the same problem ?  
Can anyone know how to resolve it ?  
I didn’t find solution on forum 😰

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [November 4, 2019, 1:50pm UTC](https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012/2 "2019-11-04T13:50:57Z")

</div>

Hi @signum-net

Using the `pragma cipher_compatibility` settings are only for the current active connection. When you wish to adjust the behavior of future connections (such as invoking the ATTACH statement), you should use the `pragma cipher_default_compatibility` setting. Additional documentation on this is available [here](https://www.zetetic.net/sqlcipher/sqlcipher-api/#cipher_default_compatibility). Would you give that a try and let us know your results?

---

<div class="post-metadata">

**Author:** ![signum-net](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/signum-net/32/2107_2.png) [@signum-net](https://discuss.zetetic.net/u/signum-net)\
**Post date:** [November 5, 2019, 12:23pm UTC](https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012/3 "2019-11-05T12:23:54Z")

</div>

Good morning  
Thank you very much for your help.

It seems it is working now with sqlcipher.dll 😀, but much slower than previous version (your build of sqlite3.dll) 🤔

About 1,000 inserts takes about 3 times more time 🤔

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [November 5, 2019, 5:36pm UTC](https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012/4 "2019-11-05T17:36:02Z")

</div>

Hello @signum-net

We are happy to hear everything is working properly now. With regard to performance, there was a large increase in iteration length for PBKDF2 in SQLCipher 4, among other security improvements. You can review all the changes detailed [here](https://www.zetetic.net/blog/2018/11/30/sqlcipher-400-release/). Are you wrapping your batch inserts within a transaction? If not, doing so will improve the performance of your insert operations. You may wish to review our general performance guidance [here](https://discuss.zetetic.net/t/sqlcipher-performance-optimization/14) in relation to your application.

---

<div class="post-metadata">

**Author:** ![signum-net](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/signum-net/32/2107_2.png) [@signum-net](https://discuss.zetetic.net/u/signum-net)\
**Post date:** [November 7, 2019, 12:54pm UTC](https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012/5 "2019-11-07T12:54:39Z")

</div>

Good Morning

Yes, all operations are in one transaction - but this “massive” operations including several thousands of inserts takes part only one time, while migrating data from other application - so it is not important.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![signum-net](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/signum-net/32/2107_2.png) [@signum-net](https://discuss.zetetic.net/u/signum-net)\
**Post date:** [November 7, 2019, 2:09pm UTC](https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012/6 "2019-11-07T14:09:21Z")

</div>

Previously, I received your building of sqlite3.dll and sqlite3.exe, but now I received only sqlcipher.dll. How can I get sqlite3.exe using sqlcipher.dll current version ?

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [November 7, 2019, 9:09pm UTC](https://discuss.zetetic.net/t/attaching-databases-using-backwards-compatibility/4012/7 "2019-11-07T21:09:13Z")

</div>

Hello @signum-net

We have reached out directly regarding this.
