I am trying to insert a Pandas dataframe into Clickhouse.
This is my code
import pandas
import sqlalchemy as sa
uri = 'clickhouse://default:@localhost/default'
ch_db = sa.create_engine(uri)
pdf = pandas.DataFrame.from_records([
{'year': 1994, 'first_name': 'Vova'},
{'year': 1995, 'first_name': 'Anja'},
{'year': 1996, 'first_name': 'Vasja'},
{'year': 1997, 'first_name': 'Petja'},
])
pdf.to_sql('test_humans', ch_db, if_exists='append', index=False)
And this is the error that I am receiving. Does this have to do with some missing extra arguments regarding the ENGINE? How can I fix this?
Exception: Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 65 (line 7, col 2): FORMAT TabSeparatedWithNamesAndTypes. Expected one of: ENGINE, storage definition (version 19.15.2.2 (official build))
Logging
INFO:sqlalchemy.engine.base.Engine:EXISTS TABLE test_humans INFO:sqlalchemy.engine.base.Engine:{} INFO:sqlalchemy.engine.base.Engine: CREATE TABLE test_humans ( first_name TEXT, year BIGINT )
INFO:sqlalchemy.engine.base.Engine:{} INFO:sqlalchemy.engine.base.Engine:ROLLBACK