Skip to content

Commit ca2c79e

Browse files
committed
Add GetProgressBar to Connections
1 parent ec8c789 commit ca2c79e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/include/duckdb/web/webdb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class WebDB {
3333
public:
3434
/// A connection
3535
class Connection {
36+
friend WebDB;
37+
3638
protected:
3739
/// The webdb
3840
WebDB& webdb_;

lib/src/webdb.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,29 @@ std::string WebDB::Tokenize(std::string_view text) {
783783
/// Get the version
784784
std::string_view WebDB::GetVersion() { return database_->LibraryVersion(); }
785785

786+
class ProgressBarCustom: public ProgressBarDisplay {
787+
public:
788+
ProgressBarCustom() {
789+
}
790+
~ProgressBarCustom() {}
791+
public:
792+
void Update(double percentage) {
793+
std::cout << "ProgressBar::Update() called with " << percentage << "\n";
794+
}
795+
void Finish() {
796+
std::cout << "Finish() called\n";
797+
}
798+
static unique_ptr<ProgressBarDisplay> GetProgressBar() {
799+
return make_uniq<ProgressBarCustom>();
800+
}
801+
};
802+
786803
/// Create a session
787804
WebDB::Connection* WebDB::Connect() {
788805
auto conn = duckdb::make_uniq<WebDB::Connection>(*this);
789806
auto conn_ptr = conn.get();
790807
connections_.insert({conn_ptr, std::move(conn)});
808+
ClientConfig::GetConfig(*conn_ptr->connection_.context).display_create_func = ProgressBarCustom::GetProgressBar;
791809
return conn_ptr;
792810
}
793811

0 commit comments

Comments
 (0)