Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stream-based prepared statemenet #1163

Merged
merged 3 commits into from
Dec 30, 2022
Merged

Add stream-based prepared statemenet #1163

merged 3 commits into from
Dec 30, 2022

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