# Using CrateDB Cloud from Jupyter Lab

**URL:** <https://community.cratedb.com/t/using-cratedb-cloud-from-jupyter-lab/1372>\
**Category:** CrateDB Cloud\
**Created:** [February 12, 2023, 10:23pm UTC](https://community.cratedb.com/t/using-cratedb-cloud-from-jupyter-lab/1372 "2023-02-12T22:23:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Georg\_Boegerl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/georg_boegerl/32/811_2.png) [@Georg\_Boegerl](https://community.cratedb.com/u/Georg_Boegerl)\
**Post date:** [February 12, 2023, 10:23pm UTC](https://community.cratedb.com/t/using-cratedb-cloud-from-jupyter-lab/1372/1 "2023-02-12T22:23:23Z")

</div>

I tried accessing my sample database on CrateCloud from JuypterLab.

```auto
%sql crate://[user]:[password]@[host]:4200
%sql SELECT * FROM doc.sample_event LIMIT 10

```

But i get the error message:

`(crate.client.exceptions.ConnectionError) No more Servers available, exception from last server: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))`

I receive the same error message using SQL alchemy and reading in pandas.

I have no problems accessing the database from DBeaver or Metabase.

Any hints?

---

<div class="post-metadata">

**Author:** ![Georg\_Boegerl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/georg_boegerl/32/811_2.png) [@Georg\_Boegerl](https://community.cratedb.com/u/Georg_Boegerl)\
**Post date:** [February 13, 2023, 8:42am UTC](https://community.cratedb.com/t/using-cratedb-cloud-from-jupyter-lab/1372/2 "2023-02-13T08:42:09Z")

</div>

I did some more tests accessing Crate from JupyterLab. Using Crate Python driver (= same approach as with my working Python scripts):

```python
from crate import client as crate
conn = crate.connect("HOST:4200", username="USERNAME", password="PASSWORD", verify_ssl_cert=True)
cursor = conn.cursor()
cursor.execute("SELECT * FROM sample_event LIMIT 10")

```

It seems that there is some issue running it from within JupyterLab.  
Still get the same error:

`ConnectionError: No more Servers available, exception from last server: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))`

Any hints?

---

<div class="post-metadata">

**Author:** ![proddata](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/proddata/32/1379_2.png) [@proddata](https://community.cratedb.com/u/proddata)\
**Post date:** [February 13, 2023, 8:49am UTC](https://community.cratedb.com/t/using-cratedb-cloud-from-jupyter-lab/1372/3 "2023-02-13T08:49:33Z")

</div>

Are you using `https` in front of the hostname? (CrateDB Cloud does not allow connections without TLS).  
In the cloud console, there should be code snippets in “Learn how to connect” that should work.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/crate/original/1X/65a53d48af22daf1d897e878a9ecd0aa29ecb383.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/crate/original/1X/883bda6b4cd6ae12cfe32ee34b77fbecda44bbb8.png)

---

<div class="post-metadata">

**Author:** ![Georg\_Boegerl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/georg_boegerl/32/811_2.png) [@Georg\_Boegerl](https://community.cratedb.com/u/Georg_Boegerl)\
**Post date:** [February 13, 2023, 9:13am UTC](https://community.cratedb.com/t/using-cratedb-cloud-from-jupyter-lab/1372/4 "2023-02-13T09:13:33Z")

</div>

Yes - that worked for the crate-driver!

conn = crate.connect(“[https://HOST:4200](https://HOST:4200)”, username=“USERNAME”, password=“PASSWORD”, verify\_ssl\_cert=True)

Do you have any idea where to put in Jupyter SQL? As far I understand the connection string should look like this:

%sql crate://USERNAME:PASSWORD@HOST:4200

But I have no idea how to enforce https here?!?  
It would be much more convenient for the data analyst to work directly with the SQL-magic.

---

<div class="post-metadata">

**Author:** ![proddata](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/proddata/32/1379_2.png) [@proddata](https://community.cratedb.com/u/proddata)\
**Post date:** [February 13, 2023, 9:28am UTC](https://community.cratedb.com/t/using-cratedb-cloud-from-jupyter-lab/1372/5 "2023-02-13T09:28:35Z")

</div>

I need to check that, but I think

```auto
%sql crate://USERNAME:PASSWORD@HOST:4200/?ssl=true

```

should work.

> **[SQLAlchemy support](https://crate.io/docs/python/en/latest/sqlalchemy.html#database-urls)**
>
> Table of contents Introduction, Connecting- Database URLs, Getting a connection., Tables- Table definition, Extension types., Querying- Aggregate f...

* * *

Will take this as input to improve documentation.

---

<div class="post-metadata">

**Author:** ![Georg\_Boegerl](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/georg_boegerl/32/811_2.png) [@Georg\_Boegerl](https://community.cratedb.com/u/Georg_Boegerl)\
**Post date:** [February 13, 2023, 9:35am UTC](https://community.cratedb.com/t/using-cratedb-cloud-from-jupyter-lab/1372/6 "2023-02-13T09:35:56Z")

</div>

Awesome - yes, works perfectly! Thank you!  
I think one challenge for me was that most examples in the documentation assume a deployment on localhost and the sample project for Jupyter did not include the SQL-magic.

For you reference this is my test code (perhaps useful for others):

```python
import crate
import sqlalchemy
from sqlalchemy import create_engine
import pandas as pd

%load_ext sql

%sql crate://USERNAME:PASSWORD@HOST:4200?ssl=True

%%sql rs <<
SELECT * FROM sample_event LIMIT 10

df = rs.DataFrame()
df

```
