Author: jbellis
Date: Wed Apr 13 15:02:00 2011
New Revision: 1091812
URL: http://svn.apache.org/viewvc?rev=1091812&view=rev
Log:
update cqlsh for python dbapi driver
Modified:
cassandra/branches/cassandra-0.8/drivers/py/cql/errors.py
cassandra/branches/cassandra-0.8/drivers/py/cqlsh
Modified: cassandra/branches/cassandra-0.8/drivers/py/cql/errors.py
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/drivers/py/cql/errors.py?rev=1091812&r1=1091811&r2=1091812&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/drivers/py/cql/errors.py (original)
+++ cassandra/branches/cassandra-0.8/drivers/py/cql/errors.py Wed Apr 13
15:02:00 2011
@@ -15,8 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__all__ = ['InvalidCompressionScheme', 'CQLException', 'InvalidQueryFormat']
+__all__ = ['InvalidCompressionScheme', 'InvalidQueryFormat']
class InvalidCompressionScheme(Exception): pass
class InvalidQueryFormat(Exception): pass
-class CQLException(Exception): pass
Modified: cassandra/branches/cassandra-0.8/drivers/py/cqlsh
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/drivers/py/cqlsh?rev=1091812&r1=1091811&r2=1091812&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/drivers/py/cqlsh (original)
+++ cassandra/branches/cassandra-0.8/drivers/py/cqlsh Wed Apr 13 15:02:00 2011
@@ -26,14 +26,11 @@ import os
import re
try:
- from cql import Connection
- from cql.errors import CQLException
- from cql.results import RowsProxy
+ import cql
except ImportError:
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
- from cql import Connection
- from cql.errors import CQLException
- from cql.results import RowsProxy
+ import cql
+from cql.results import ResultSet
HISTORY = os.path.join(os.path.expanduser('~'), '.cqlsh')
CQLTYPES = ("bytes", "ascii", "utf8", "timeuuid", "uuid", "long", "int")
@@ -55,10 +52,7 @@ class Shell(cmd.Cmd):
def __init__(self, hostname, port, color=False, username=None,
password=None):
cmd.Cmd.__init__(self)
- self.conn = Connection(hostname,
- port=port,
- username=username,
- password=password)
+ self.conn = cql.connect(hostname, port, user=username,
password=password)
if os.path.exists(HISTORY):
readline.read_history_file(HISTORY)
@@ -92,10 +86,11 @@ class Shell(cmd.Cmd):
statement = self.get_statement(arg)
if not statement: return
- result = self.conn.execute(statement)
+ cursor = self.conn.cursor()
+ cursor.execute(statement)
- if isinstance(result, RowsProxy):
- for row in result:
+ if isinstance(cursor.result, ResultSet):
+ for row in cursor.result.rows:
self.printout(row.key, BLUE, False)
for column in row.columns:
self.printout(" | ", newline=False)
@@ -105,7 +100,7 @@ class Shell(cmd.Cmd):
self.printout(repr(column.value), YELLOW, False)
self.printout("")
else:
- if result: print result
+ if cursor.result: print cursor.result[0]
def emptyline(self):
pass
@@ -221,7 +216,7 @@ if __name__ == '__main__':
except SystemExit:
readline.write_history_file(HISTORY)
break
- except CQLException, cqlerr:
+ except cql.Error, cqlerr:
shell.printerr(str(cqlerr), color=RED)
except KeyboardInterrupt:
shell.reset_statement()