cloudflare / cloudflare/sqlalchemy-clickhouse
Cannot insert with 'add'-statement
- Dominant language
- Python
- Stars
- 325
- Forks
- 101
- PR merge metrics
- No merged PRs in 30d
Description
Table:
```
class MyTable(Base):
__tablename__ = "mytable"
col1 = Column(String, primary_key=True)
col2 = Column(String)
```
Trying to insert data:
```
ch_session.add(ch_module.MyTable(col1="test1", col2="test2"))
ch_session.commit()
```
Result:
```
self =
data = b"INSERT INTO mytable (col1, col2) VALUES ('test1', 'test2') FORMAT TabSeparatedWithNamesAndTypes"
settings = {'query_id': UUID('3b378a94-3d62-11e8-a334-001a7dda7113')}
stream = True
def _send(self, data, settings=None, stream=False):
if PY3 and isinstance(data, string_types):
data = data.encode('utf-8')
params = self._build_params(settings)
r = requests.post(self.db_url, params=params, data=data, stream=stream)
if r.status_code != 200:
> raise Exception(r.text)
E Exception: Code: 27, e.displayText() = DB::Exception: Cannot parse input: expected ( before: FORMAT TabSeparatedWithNamesAndTypes: (at row 2)
E , e.what() = DB::Exception
```
The error occurs in `select` method of `infi.sliskhouse_orm.database.Database` - there is adding `FORMAT` expression and final version of query is `'INSERT INTO mytable (col1, col2) VALUES (\\'test1\\', \\'test2\\') FORMAT TabSeparatedWithNamesAndTypes'`
Is there any way to avoid this error?
Version info:
```
pip freeze
sqlalchemy-clickhouse==0.1.3.post0
infi.clickhouse-orm==0.9.8
SQLAlchemy==1.2.6
```
Contributor guide
Assessment
This issue has not been assessed yet.