Skip to content

Commit 10ef2a3

Browse files
committed
uploading csv to datasource
1 parent 15c6040 commit 10ef2a3

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed

clickhouse_mysql/writer/chcsvwriter.py

+3-36
Original file line numberDiff line numberDiff line change
@@ -68,44 +68,11 @@ def insert(self, event_or_events=None):
6868
logging.debug('class:%s insert %d rows', __class__, len(events))
6969

7070
for event in events:
71-
schema = self.dst_schema if self.dst_schema else event.schema
72-
table = None
73-
if self.dst_distribute:
74-
table = TableProcessor.create_distributed_table_name(db=event.schema, table=event.table)
75-
else:
76-
table = self.dst_table if self.dst_table else event.table
77-
if self.dst_schema:
78-
table = TableProcessor.create_migrated_table_name(prefix=self.dst_table_prefix, table=table)
79-
80-
sql = 'INSERT INTO `{0}`.`{1}` ({2}) FORMAT CSV'.format(
81-
schema,
82-
table,
83-
', '.join(map(lambda column: '`%s`' % column, event.fieldnames)),
84-
)
85-
86-
choptions = ""
87-
if self.host:
88-
choptions += " --host=" + shlex.quote(self.host)
89-
if self.port:
90-
choptions += " --port=" + str(self.port)
91-
if self.user:
92-
choptions += " --user=" + shlex.quote(self.user)
93-
if self.password:
94-
choptions += " --password=" + shlex.quote(self.password)
95-
bash = "tail -n +2 '{0}' | clickhouse-client {1} --query='{2}'".format(
96-
event.filename,
97-
choptions,
98-
sql,
99-
)
100-
101-
# logging.info('starting clickhouse-client process')
102-
# logging.debug('starting %s', bash)
103-
# os.system(bash)
104-
105-
logging.info('calling Tinybird')
71+
#schema = self.dst_schema if self.dst_schema else event.schema
72+
#table = self.dst_table if self.dst_table else event.table
10673

10774
params = {
108-
'name': 'schedulings_ins',
75+
'name': self.dst_table,
10976
'mode': 'append'
11077
}
11178
token = 'p.eyJ1IjogIjUzMWUwMDUxLTRmZGQtNDc5MC05OGY0LWNlNTA3NDVkYzFkNSIsICJpZCI6ICIzNzMyOWExNy1mMGM2LTQyNWMtODhmOC1hZDE2MTU4OWIwNmMifQ.80_ZbRL9D8x2mlWay1EjdeA-zi7asxqKqp06NoOmadg'

0 commit comments

Comments
 (0)