Connection

>>> from crate.client import connect

We create a new connection object:

>>> connection = connect(client=connection_client_mocked)

Calling the cursor() function on the connection will return a cursor object:

>>> cursor = connection.cursor()

Now we are able to perform any operation provided by the cursor object:

>>> cursor.rowcount
-1

Now we close the connection:

>>> connection.close()

The connection will be unusable from this point. Any operation attempted with the closed connection will raise a ProgrammingError:

>>> cursor = connection.cursor()
Traceback (most recent call last):
...
ProgrammingError: Connection closed

>>> cursor.execute('')
Traceback (most recent call last):
...
ProgrammingError: Connection closed

>>> connection.commit()
Traceback (most recent call last):
...
ProgrammingError: Connection closed

>>> connection = connect(client=connection_client_mocked)
>>> cursor = connection.cursor()
>>> cursor.rowcount
-1