Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

UnboundLocalError when I try to get column family #82

Closed
spoksss opened this issue Sep 25, 2011 · 1 comment
Closed

UnboundLocalError when I try to get column family #82

spoksss opened this issue Sep 25, 2011 · 1 comment

Comments

@spoksss
Copy link

spoksss commented Sep 25, 2011

Hi,

I have just started with cassandra, so don't know if this should be realy reported as a bug,

If one try to get column family but haven't created that column family/keyspace
using pycassaShell will get error,

>>> keyspace = "test_ks"
>>> column_family = "test_cf"
>>> pool = pycassa.connect(keyspace)
>>> col_fam = pycassa.ColumnFamily(pool, column_family)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pycassa/columnfamily.py", line 252, in __init__
    self.load_schema()
  File "pycassa/columnfamily.py", line 269, in load_schema
    use_dict_for_col_metadata=True)
  File "pycassa/pool.py", line 573, in execute
    self.put(conn)
UnboundLocalError: local variable 'conn' referenced before assignment

I got this error, checked what happen and I created keyspace and column family,
and haven't got that error again,

pycassaShell
[I]: IPython not found, falling back to default interpreter.
----------------------------------
Cassandra Interactive Python Shell
---------------------------------- 
Keyspace: None
Host: localhost:9160

 ColumnFamily instances are only available if a keyspace is specified with -k/--keyspace

Schema definition tools and cluster information are available through SYSTEM_MANAGER.
>>> SYSTEM_MANAGER.create_keyspace('test_ks', replication_factor=1)
>>> SYSTEM_MANAGER.create_column_family('test_ks','test_cf')
>>>

>>> pool = pycassa.connect(keyspace) 
>>> col_fam = pycassa.ColumnFamily(pool, column_family)
>>> row_id_1 = "1"
>>> col_fam.insert(row_id_1, {'name':'Some name'})

My env:
python: 2.6.5
cassandra: 0.8.6
pycassa: 1.2.0

@thobbs thobbs closed this as completed in 38b64fa Sep 25, 2011
@thobbs
Copy link
Member

thobbs commented Sep 25, 2011

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants