jaydebeapi
jaydebeapi copied to clipboard
Error if I do fetchall after 'CREATE TABLE' query
Hi
I've got an error in fetchall()
if I call it after execute("CREATE TABLE...")
:
Error Traceback (most recent call last)
<ipython-input-12-d35fc1caa8d6> in <module>()
----> 1 cursor.fetchall()
/usr/local/lib/python2.7/dist-packages/jaydebeapi/__init__.pyc in fetchall(self)
558 rows = []
559 while True:
--> 560 row = self.fetchone()
561 if row is None:
562 break
/usr/local/lib/python2.7/dist-packages/jaydebeapi/__init__.pyc in fetchone(self)
523 def fetchone(self):
524 if not self._rs:
--> 525 raise Error()
526 if not self._rs.next():
527 return None
Error:
If it's SELECT query, then everything is ok. If it's other library (not jaydebeapi), then it's also ok (empty data and colums are returned).
Here is code:
query = "CREATE TABLE my_table AS SELECT ..."
import jaydebeapi
connection = jaydebeapi.connect(...)
cursor = connection.cursor()
cursor.execute(query)
data = cursor.fetchall()
columns = [i[0] for i in cursor.description]
cursor.close()
connection.close()
Fix it please
Thanks in advance
This error appears when query does not return anything. Like, MSCK REPAIR TABLE or ALTER TABLE. Im trying to workaround this but this is just bad design... Please fix this...
@baztian Any update on this issue? Facing this while executing any query which does not return an output. Thanks!