<p>The introduction of <a href="https://bitcoin.stackexchange.com/questions/99540/what-are-output-descriptors">descriptor wallets</a> presents an opportunity to introduce a new database backend as descriptor wallets are backwards incompatible. The following is taken from Andrew Chow's <a href="https://achow101.com/2020/10/0.21-wallets" rel="nofollow noreferrer">blog post</a> on what's coming to the Bitcoin Core wallet in 0.21. (There was also discussion on this GitHub <a href="https://github.com/bitcoin/bitcoin/issues/18916" rel="nofollow noreferrer">Issue</a>.)</p>
<p><strong>Why move from Berkeley DB?</strong></p>
<ul>
<li>Not designed to be used as an application data file. The Legacy Wallet has several hacks to get round this as a result and Berkeley DB wallet files can easily be corrupted.</li>
<li>Berkeley DB produces extra files which need to be moved with the database file. This means that Berkeley DB is less portable and requires a directory for each wallet.</li>
<li>Changes were introduced to Berkeley DB database environment files breaking backwards compatibility.</li>
</ul>
<p><strong>Why choose SQLite?</strong></p>
<ul>
<li><p>Can be used as an application data file.</p>
</li>
<li><p>New SQLite versions maintains backwards compatibility with versions as far back as 2013.</p>
</li>
<li><p>Does not require database environment. A completed write guarantees that the data was written to the database file.</p>
</li>
<li><p>Can now move to single wallet files instead of wallet directories.</p>
</li>
</ul>
<p>Here is the proposed <a href="https://github.com/bitcoin/bitcoin/issues/20160" rel="nofollow noreferrer">timeline</a> for legacy wallet and Berkeley DB removal from Bitcoin Core.</p>

CC BY-SA 4.0
2020-10-25T07:39:28.310Z
There is also the fact that SQLite is easily the most robust, reliable, and heavily tested DB engine. It is probably also some of the most robust, reliable, and heavily tested code, *period*, except maybe the aerospace industry. Maybe even better (*cough* Boeing *cough*). Their [testing regime](https://sqlite.org/testing.html) and approach to robustness and reliability is truly *insane*. For each line of code, there are 640 lines of tests.
Jörg W Mittag
CC BY-SA 4.0
2020-10-24T12:19:21.160Z
2020-10-29T20:11:20.963Z
2020-10-29T20:11:20.963Z
Michael Folkson
<p>Why is the Bitcoin Core wallet moving from Berkeley DB to SQLite for its database backend?</p>

<wallet><bitcoin-core-development><wallet.dat><database>
Why is the Bitcoin Core wallet database moving from Berkeley DB to SQLite?
Michael Folkson
# Why is the Bitcoin Core wallet database moving from Berkeley DB to SQLite?

(Asked by: username_0 on 2020-10-24)

Why is the Bitcoin Core wallet moving from Berkeley DB to SQLite for its database backend?

**Tags:** wallet, bitcoin-core-development, wallet.dat, database


---

## 1 answers

### Answer by username_0 on 2020-10-24. Score: 10 | Accepted answer

The introduction of [descriptor wallets](https://bitcoin.stackexchange.com/questions/99540/what-are-output-descriptors) presents an opportunity to introduce a new database backend as descriptor wallets are backwards incompatible. The following is taken from Andrew Chow's [blog post](https://achow101.com/2020/10/0.21-wallets) on what's coming to the Bitcoin Core wallet in 0.21. (There was also discussion on this GitHub [Issue](https://github.com/bitcoin/bitcoin/issues/18916).)

**Why move from Berkeley DB?**

* Not designed to be used as an application data file. The Legacy Wallet has several hacks to get round this as a result and Berkeley DB wallet files can easily be corrupted.
* Berkeley DB produces extra files which need to be moved with the database file. This means that Berkeley DB is less portable and requires a directory for each wallet.
* Changes were introduced to Berkeley DB database environment files breaking backwards compatibility.

**Why choose SQLite?**

* Can be used as an application data file.
* New SQLite versions maintains backwards compatibility with versions as far back as 2013.
* Does not require database environment. A completed write guarantees that the data was written to the database file.
* Can now move to single wallet files instead of wallet directories.

Here is the proposed [timeline](https://github.com/bitcoin/bitcoin/issues/20160) for legacy wallet and Berkeley DB removal from Bitcoin Core.

> **Comments:**
> **username_1**: There is also the fact that SQLite is easily the most robust, reliable, and heavily tested DB engine. It is probably also some of the most robust, reliable, and heavily tested code, *period*, except maybe the aerospace industry. Maybe even better (*cough* Boeing *cough*). Their [testing regime](https://sqlite.org/testing.html) and approach to robustness and reliability is truly *insane*. For each line of code, there are 640 lines of tests.  

---

