Skip to main content

DuckDB Integration

Using BioBear with DuckDB is straightforward. First, use BioBear to generate an Arrow RecordBatch Reader from your data. Then use the DuckDB Python package to read from that reader.

import biobear as bb
import duckdb

session = bb.connect()

session.sql("""
CREATE EXTERNAL TABLE gene_annotations STORED AS GFF LOCATION 'python/tests/data/test.gff'
""")

result = session.sql("""
SELECT * FROM gene_annotations
""")

gff_table_arrow_table = result.to_arrow()

duckdb_conn = duckdb.connect()

result = duckdb_conn.execute('SELECT * FROM gff_table_arrow_table').fetchall()
print(result)