Skip to content

Commit 9e66ac3

Browse files
committed
Documentation: Strip idiomatic REPL prompt from landing page examples
Replicating the REPL prompt is nice and all, and the `sphinx-copybutton` addon will nicely filter it when copy/pasting the code snippet. However, not all people have JavaScript enabled, and it will probably also fall short on accessibility aspects, and nothing of this kind will ever be found on other code examples, so let's remove it.
1 parent be7ac6b commit 9e66ac3

1 file changed

Lines changed: 46 additions & 46 deletions

File tree

docs/index.rst

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,34 @@ Install package from PyPI.
5858

5959
.. code-block:: shell
6060
61-
$ pip install crate
61+
pip install crate
6262
6363
Connect to CrateDB instance running on ``localhost``.
6464

6565
.. code-block:: python
6666
67-
>>> # Connect using DB API.
68-
>>> from pprint import pp
69-
>>> from crate import client
70-
>>>
71-
>>> query = "SELECT country, mountain, coordinates, height FROM sys.summits ORDER BY country;"
72-
>>>
73-
>>> with client.connect("localhost:4200", username="crate") as connection:
74-
... cursor = connection.cursor()
75-
... cursor.execute(query)
76-
... pp(cursor.fetchall())
77-
... cursor.close()
67+
# Connect using DB API.
68+
from crate import client
69+
from pprint import pp
70+
71+
query = "SELECT country, mountain, coordinates, height FROM sys.summits ORDER BY country;"
72+
73+
with client.connect("localhost:4200", username="crate") as connection:
74+
cursor = connection.cursor()
75+
cursor.execute(query)
76+
pp(cursor.fetchall())
77+
cursor.close()
7878
7979
Connect to `CrateDB Cloud`_.
8080

8181
.. code-block:: python
8282
83-
>>> # Connect using DB API.
84-
>>> from crate import client
85-
>>> connection = client.connect(
86-
... servers="https://example.aks1.westeurope.azure.cratedb.net:4200",
87-
... username="admin",
88-
... password="<PASSWORD>")
83+
# Connect using DB API.
84+
from crate import client
85+
connection = client.connect(
86+
servers="https://example.aks1.westeurope.azure.cratedb.net:4200",
87+
username="admin",
88+
password="<PASSWORD>")
8989
9090
9191
SQLAlchemy
@@ -104,49 +104,49 @@ Install package from PyPI with DB API and SQLAlchemy support.
104104

105105
.. code-block:: shell
106106
107-
$ pip install 'crate[sqlalchemy]' pandas
107+
pip install 'crate[sqlalchemy]' pandas
108108
109109
Connect to CrateDB instance running on ``localhost``.
110110

111111
.. code-block:: python
112112
113-
>>> # Connect using SQLAlchemy Core.
114-
>>> from pprint import pp
115-
>>> import sqlalchemy as sa
116-
>>>
117-
>>> dburi = "crate://localhost:4200"
118-
>>> query = "SELECT country, mountain, coordinates, height FROM sys.summits ORDER BY country;"
119-
>>>
120-
>>> engine = sa.create_engine(dburi, echo=True)
121-
>>> with engine.connect() as connection:
122-
... with connection.execute(sa.text(query)) as result:
123-
... pp(result.mappings().fetchall())
113+
# Connect using SQLAlchemy Core.
114+
import sqlalchemy as sa
115+
from pprint import pp
116+
117+
dburi = "crate://localhost:4200"
118+
query = "SELECT country, mountain, coordinates, height FROM sys.summits ORDER BY country;"
119+
120+
engine = sa.create_engine(dburi, echo=True)
121+
with engine.connect() as connection:
122+
with connection.execute(sa.text(query)) as result:
123+
pp(result.mappings().fetchall())
124124
125125
Connect to `CrateDB Cloud`_.
126126

127127
.. code-block:: python
128128
129-
>>> # Connect using SQLAlchemy Core.
130-
>>> import sqlalchemy as sa
131-
>>> dburi = "crate://admin:<PASSWORD>@example.aks1.westeurope.azure.cratedb.net:4200?ssl=true"
132-
>>> engine = sa.create_engine(dburi, echo=True)
129+
# Connect using SQLAlchemy Core.
130+
import sqlalchemy as sa
131+
dburi = "crate://admin:<PASSWORD>@example.aks1.westeurope.azure.cratedb.net:4200?ssl=true"
132+
engine = sa.create_engine(dburi, echo=True)
133133
134134
Load results into `pandas`_ DataFrame.
135135

136136
.. code-block:: python
137137
138-
>>> # Connect using SQLAlchemy Core and pandas.
139-
>>> import pandas as pd
140-
>>> import sqlalchemy as sa
141-
>>>
142-
>>> dburi = "crate://localhost:4200"
143-
>>> query = "SELECT * FROM sys.summits ORDER BY country;"
144-
>>>
145-
>>> engine = sa.create_engine(dburi, echo=True)
146-
>>> with engine.connect() as connection:
147-
... df = pd.read_sql(sql=sa.text(query), con=connection)
148-
... df.info()
149-
... print(df)
138+
# Connect using SQLAlchemy Core and pandas.
139+
import pandas as pd
140+
import sqlalchemy as sa
141+
142+
dburi = "crate://localhost:4200"
143+
query = "SELECT * FROM sys.summits ORDER BY country;"
144+
145+
engine = sa.create_engine(dburi, echo=True)
146+
with engine.connect() as connection:
147+
df = pd.read_sql(sql=sa.text(query), con=connection)
148+
df.info()
149+
print(df)
150150
151151
152152
Data types

0 commit comments

Comments
 (0)