High-Performance Open-Source Archive
querychat supports several different data sources,
including:
DataSource interfacesThe sections below describe how to use each type of data source with
querychat.
You can use any data frame as a data source in
querychat. Simply pass it to querychat():
Behind the scenes, querychat creates an in-memory DuckDB
database and registers your data frame as a table for SQL query
execution.
You can also connect querychat directly to a table in
any database supported by DBI. This
includes popular databases like SQLite, DuckDB, PostgreSQL, MySQL, and
many more.
Assuming you have a database set up and accessible, you can create a
DBI connection and pass it to querychat(). Below are some
examples for common databases.
library(DBI)
library(RPostgres)
library(querychat)
# Connect to PostgreSQL
con <- dbConnect(
RPostgres::Postgres(),
host = "localhost",
port = 5432,
dbname = "mydatabase",
user = "myuser",
password = "mypassword"
)
qc <- querychat(con, "my_table")
qc$app() # Launch the app
# Don't forget to disconnect when done
# dbDisconnect(con)library(DBI)
library(RMariaDB)
library(querychat)
# Connect to MySQL
con <- dbConnect(
RMariaDB::MariaDB(),
host = "localhost",
port = 3306,
dbname = "mydatabase",
user = "myuser",
password = "mypassword"
)
qc <- querychat(con, "my_table")
qc$app() # Launch the app
# Don't forget to disconnect when done
# dbDisconnect(con)If you don’t have a database set up, you can easily create a local DuckDB database from a data frame:
library(DBI)
library(duckdb)
con <- dbConnect(duckdb::duckdb(), dbdir = "my_database.duckdb")
# Write a data frame to the database
dbWriteTable(con, "penguins", penguins)
# Or from CSV
duckdb::duckdb_read_csv(con, "my_table", "path/to/your/file.csv")Then you can connect to this database using the DuckDB example above.
If you have a custom data source that doesn’t fit into the above
categories, you can implement the DataSource interface. See
the DataSource reference for
more details on implementing this interface.
Need mirroring services?
Contact our team at info@vpspulse.com.
Mirror powered by VPSpulse
Infrastructure sponsored by VPSPulse & Secure Payments by ArionPay.