Skip to content

Conversation

zhicwu
Copy link
Contributor

@zhicwu zhicwu commented Dec 30, 2022

Take format clause as hint for stream-based insertion.

try (PreparedStatement ps = conn.preparedStatement("insert into mytable(col1,col2,col3) format CSV")) {
  ps.setString(1, "1,2,3");
  ps.addBatch();
  ps.setBinaryStream(1, new ByteArrayInputStream("4,5,6".getBytes()));
  ps.addBatch();
  ps.setObject(1, new ClickHouseWriter() { // callback runs in a separate worker thread
      @Override
      public void write(ClickHouseOutputStream out) throws IOException {
          out.write("7,8,9".getBytes());
      }
  });
  ps.addBatch();
  ps.setObject(1, new File("/tmp/my.csv"));
  ps.addBatch();
  ps.executeBatch();
}

@Neyzoter
Copy link

How can i insert DateTime in stream?

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

Successfully merging this pull request may close these issues.

2 participants