Before you start
You’ll need:- A Dataville account and its API key, from the API Keys page.
- The DuckDB command-line tool, from the DuckDB installation page.
Query SEC filings with DuckDB
Put both files from these steps in one folder, and run the script from that folder.1
Download the company list
The company list is a CSV file with a The file looks like this:
ticker column and a segment column for your own notes. It has the three example companies from Analyze Competitors Using SEC EDGAR Filings.sector.csv
Download the company list with the example companies.
2
Download the DuckDB SQL script
The script is for the DuckDB command-line tool. It looks up each ticker in the
edgar source, which returns the company’s CIK, the SEC’s number for a filer. It then sends Dataville a query for those companies’ filings from the last 12 months, matches each filing to its company by CIK, and saves the result as sector-filings.csv.sector.sql
Download the DuckDB script.
View sector.sql
View sector.sql
3
Run the script
Set your API key, then run the script in the same terminal:The script sends your key in a request header, so it never appears in a URL. It writes If the script stops with “Set DATAVILLE_API_KEY to your Dataville API key first.”, set the key in the same terminal and run it again.Here are the Floor & Decor rows of
sector-filings.csv to the same folder and prints how many filings each company has. For the example companies on October 16, 2026, it printed:sector-filings.csv, without the company_name and document_url columns:An 8-K’s items say what it reports. Item 2.02 is an earnings release, and 5.02 is a change of directors or officers. Item 5.07 is a shareholder vote, and 2.03 is a new financial obligation, such as a loan. Floor & Decor’s 8-K from June 25, 2026 lists items 1.01, 1.02, and 2.03. Those are a new material agreement, the end of another, and a new financial obligation.Each run makes one data lookup per ticker and one query. Dataville charges the query for each filing it returns, and the query counts toward the limit of 1,000 per day per account.The lookup adds a company’s recent filings to the
edgar table. If a company you’ve added has no rows, run the script again. If SEC EDGAR is unavailable, the lookups come from Dataville’s stored copy and may miss the newest filings, so run the script again later. See Response format to learn more about stale results.4
Customize the query for your sector
To query filings for your own sector, replace the rows in sector.csv with the tickers of the companies you want to analyze and your notes on each one. Run the script again to retrieve their recent SEC filings and export the updated results to sector-filings.csv.
Next steps
You’ve used DuckDB to query SEC EDGAR filings through Dataville and combine the results with your own company information. Explore these related guides to learn more about querying Dataville or automating SEC filing monitoring.Query from DuckDB
How DuckDB runs a query on Dataville, and what Dataville charges for each read.
Analyze Competitors Using SEC EDGAR Filings
Compare company financial performance using SEC filings, Claude, and Dataville Data Studio.