client Package

client Package

connection Module

class crate.client.connection.Connection(servers=None, timeout=None, client=None)

Bases: object

close()

Close the connection now

commit()

Transactions are not supported, so commit is not implemented.

cursor()

Return a new Cursor Object using the connection.

crate.client.connection.connect(servers=None, timeout=None, client=None)

crash Module

crate cli

can be used to query crate using SQL

class crate.client.crash.CrateCmd(*args)

Bases: cmd.Cmd

cols()
do_connect(server)

connect to one or more server with “connect servername:port”

do_delete(statement)

execute a SQL delete statement

E.g.:
“delete from locations where name = ‘Algol’
do_exit(*args)

exit the shell

do_insert(statement)

execute a SQL insert statement

E.g.:
“insert into locations (name) values (‘Algol’)
do_quit(*args)

exit the shell

do_select(statement)

execute a SQL select statement

E.g.:
“select name from locations where name = ‘Algol’”
execute(statement)
execute_query(statement)
pprint(rows)
prompt = 'cr> '
crate.client.crash.main()

cursor Module

class crate.client.cursor.Cursor(connection)

Bases: object

close()

Close the cursor now

description

This read-only attribute is a sequence of 7-item sequences.

execute(sql)

Prepare and execute a database operation (query or command).

executemany(sql, seq_of_parameters)

Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.

fetchall()

Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor’s arraysize attribute can affect the performance of this operation.

fetchmany(count=None)

Fetch the next set of rows of a query result, returning a sequence of sequences (e.g. a list of tuples). An empty sequence is returned when no more rows are available.

fetchone()

Fetch the next row of a query result set, returning a single sequence, or None when no more data is available. Alias for next().

next()

Fetch the next row of a query result set, returning a single sequence, or None when no more data is available.

rowcount

This read-only attribute specifies the number of rows that the last .execute*() produced (for DQL statements like SELECT) or affected (for DML statements like UPDATE or INSERT).

setinputsizes(sizes)

Not supported method.

setoutputsize(size, column=None)

Not supported method.

exceptions Module

exception crate.client.exceptions.ConnectionError

Bases: exceptions.Exception

Crate HTTP API Exception

exception crate.client.exceptions.ProgrammingError

Bases: exceptions.Exception

Base class for exceptions in this module.

http Module

class crate.client.http.Client(servers=None, timeout=None)

Bases: object

Crate connection client using crate’s HTTP API.

default_server = '127.0.0.1:9200'

Default server to use if no servers are given on instantiation.

retry_interval = 30

Retry interval for failed servers in seconds.

sql(stmt)

Execute SQL stmt against the crate server.

sql_path = '_sql'

Crate URI path for issuing SQL statements.

class crate.client.http.DateTimeDecoder(*args, **kargs)

Bases: json.decoder.JSONDecoder

JSON decoder which is trying to convert datetime strings to datetime objects

taken from: https://gist.github.com/abhinav-upadhyay/5300137

dict_to_object(d)