# DatabaseClient not working

**URL:** <https://talk.observablehq.com/t/databaseclient-not-working/4611>\
**Category:** Help\
**Created:** [February 9, 2021, 10:37am UTC](https://talk.observablehq.com/t/databaseclient-not-working/4611 "2021-02-09T10:37:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhirendrakellton](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/dhirendrakellton/32/4378_2.png) [@dhirendrakellton](https://talk.observablehq.com/u/dhirendrakellton)\
**Post date:** [February 9, 2021, 10:37am UTC](https://talk.observablehq.com/t/databaseclient-not-working/4611/1 "2021-02-09T10:37:58Z")

</div>

I created my notebook which plot the bar-chart with extracting data from database on my local when I am going to embed this notebook into my website then It is showing RuntimeError: DatabaseClient is not defined, how can I fix this.

---

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/hellonearthis/32/3935_2.png) [@hellonearthis](https://talk.observablehq.com/u/hellonearthis)\
**Post date:** [February 9, 2021, 1:28pm UTC](https://talk.observablehq.com/t/databaseclient-not-working/4611/2 "2021-02-09T13:28:23Z")

</div>

The most common issue is a COR error due to the local database not being on an https connecting.

These pages might help you out:

> **[Introduction to Data](https://observablehq.com/@observablehq/introduction-to-data#databases)**
>
> How do you get data into Observable for analysis and visualization? Depending on its form and where it lives, there are a variety of ways: inline - embedded in the notebook as code, for small amounts of data files - attached to the notebook, for...

> **[Self-hosted database proxies](https://observablehq.com/@observablehq/self-hosted-database-proxies)**
>
> Observable’s hosted database clients rely on an HTTPS-to-database proxy, which allows your browser to securely run SQL queries against databases that are accessible from the public internet. But if your database isn’t accessible from the public...

---

<div class="post-metadata">

**Author:** ![Cobus](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/cobus/32/9670_2.png) [@Cobus](https://talk.observablehq.com/u/Cobus)\
**Post date:** [February 9, 2021, 2:33pm UTC](https://talk.observablehq.com/t/databaseclient-not-working/4611/3 "2021-02-09T14:33:57Z")

</div>

I would love to understand this a bit better. Would you mind answering a few question?

- I assume this is a private notebook (not published) since you have a database connection? Otherwise, it would be useful to see a link to your notebook… How are you connecting to your database from the notebook?

- How are you embedding the notebook into your website? Are you actually using the embed iframe from Observable? (this would require it to be public notebook, though…)

---

<div class="post-metadata">

**Author:** ![dhirendrakellton](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/dhirendrakellton/32/4378_2.png) [@dhirendrakellton](https://talk.observablehq.com/u/dhirendrakellton)\
**Post date:** [February 9, 2021, 4:26pm UTC](https://talk.observablehq.com/t/databaseclient-not-working/4611/4 "2021-02-09T16:26:09Z")

</div>

Answering to your first question I can connect to my database only in private but I want this notebook work same fashion for where I embed this as in private

 ![Screenshot from 2021-02-09 21-42-17](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/b/bbba51fff252638443b04e8f8012d9a2e15adc17.png)  
Answering to the next question Yes I am using embed iframe from observable to imbedding notebook into my website.

---

<div class="post-metadata">

**Author:** ![Cobus](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/cobus/32/9670_2.png) [@Cobus](https://talk.observablehq.com/u/Cobus)\
**Post date:** [February 9, 2021, 4:32pm UTC](https://talk.observablehq.com/t/databaseclient-not-working/4611/5 "2021-02-09T16:32:13Z")

</div>

> [@dhirendrakellton](#):
>
> Yes I am using embed iframe from observable to imbedding notebook into my website.

Hmmm… Interesting. How are you able to embed the iframe for a private notebook? For private notebooks, the Embed link should not be enabled…

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/0/0a726c4b1178bb5239619fff2807b1d209fdf5b6.png)

---

<div class="post-metadata">

**Author:** ![dhirendrakellton](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/dhirendrakellton/32/4378_2.png) [@dhirendrakellton](https://talk.observablehq.com/u/dhirendrakellton)\
**Post date:** [February 9, 2021, 4:39pm UTC](https://talk.observablehq.com/t/databaseclient-not-working/4611/6 "2021-02-09T16:39:36Z")

</div>

After publishing my notebook I am going to embed but when I am publishing this then It shows me RuntimeError: Databases are only available in private notebooks . I want to know that How can I connect to my database so that It works .

---

<div class="post-metadata">

**Author:** ![Cobus](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/cobus/32/9670_2.png) [@Cobus](https://talk.observablehq.com/u/Cobus)\
**Post date:** [February 9, 2021, 5:59pm UTC](https://talk.observablehq.com/t/databaseclient-not-working/4611/7 "2021-02-09T17:59:37Z")

</div>

Thanks for explaining that. Now I understand. Unfortunately, you cannot publish (and hence cannot embed) a notebook with a database connection. See [DB Connections + Public Notebooks?](https://talk.observablehq.com/t/db-connections-public-notebooks/3827) where one option is to use Splitgraph…

Another recommendation is to create your own proxy server for the database as described above by @hellonearthis .
