Ask your data in plain language — no SQL required.
中文 · English | Local-first | Zero-install portable build | MIT
CioData is a local-first desktop tool (Python + CustomTkinter + Tkinter). Load Excel / CSV / Databricks data, ask in plain language, and an LLM turns it into SQL that runs locally — paginated results, one-click CSV export, and a draggable dashboard canvas for charts, pivot tables and KPIs. Strictly read-only: your source data is never modified.
- Download
CioData_portable_win64.zipfrom GitHub Releases - Unzip anywhere (don't double-click from inside the archive preview)
- Double-click
启动 CioData.bat(orportable_launcher.py) - On first launch it self-checks, then the desktop window opens in a few seconds ✅
The portable bundle already embeds the Python 3.12.10 runtime + the Databricks connector — run it from a USB stick, no Python install required.
git clone <your-fork-or-this-repo>
cd CioData
python launcher.py # auto-creates .venv, installs deps (mirror fallback), then runs
# or: double-click run.bat (Windows)
python selfcheck.py # core self-checks (524 items)launcher.py uses your system Python (3.9–3.12 recommended; 3.12 best for customtkinter), creates a local .venv, installs requirements.txt with mirror fallback, and starts the app.
To connect Databricks on the source build, double-click install_databricks.bat (one-click connector installer).
| Module | Description |
|---|---|
| 💾 Project Files | Top of the sidebar — Save Project As… / Open Project… packs the loaded data, every dashboard tile, the SQL and the ticked columns into one .cioproj; reopens anywhere, even after the source file is gone |
| 📁 Data Source | Local Excel(.xlsx/.xls)/CSV; Databricks SQL (built-in in portable, installable for source) |
| 📝 SQL Editor | Line numbers + keyword highlighting, Ctrl+Enter to run, SQLite dialect |
| 📋 Results Table | Pagination / click header to sort / double-click a cell to copy / one-click CSV export (UTF-8 BOM) |
| 📊 Dashboard | Switch to a 16:9 canvas: drag chart / pivot / KPI / text tiles anywhere, snap to grid, resize freely; layout follows the window and persists |
| 🤖 AI Chat | Natural language → SQL, one-click "Adopt & Run" or "Adopt only" |
| 🧩 SQL Snippet Storage | 10 slots by default on the top-right (adjustable 1–50): name display + edit popup + adopt into editor |
| 🧠 AI Backend | OpenAI-compatible API / local Ollama, two isolated backends |
| 🧩 Semantic Layer | YAML-defined business logic; LLM emits intent JSON only, SQL compiled deterministically; automatic tagged fallback |
| 👁️ Visible Fields | Toggle columns to show; view-only, never touches data |
| 🔄 Session Restore | Reopen and continue where you left off: data source, SQL (editor + last executed), checked columns, page, page size and AI chat |
| 📜 Run Log | Linear collapsible per-step record from YAML to SQL for every question; memory-only, cleared on exit |
| 🛠️ YAML Editor | Single-file offline HTML in the package; maintain business definitions through forms |
| 🌙 Theme / 🌐 Language | One-click light/dark toggle; Chinese/English UI switch (state preserved) |
A 💾 Project card now sits at the top of the sidebar:
- Save Project As… — the system save dialog defaults to the last-used folder (Documents the first time) and packs everything you have open — the loaded data, every dashboard tile (position, size, colours, fonts), the SQL, the ticked columns and the page number — into a single
.cioproj. - Open Project… — pick a
.cioprojand the whole workspace comes back. It works on another machine, or after the source file was deleted or renamed, because the data itself travels inside the file.
A .cioproj is a plain zip (rename it to .zip and unzip it): meta.json (source, SQL, ticked columns, paging, column names + type table, preferences) + layout.json (dashboard layout and every tile spec) + data.csv (the data snapshot). The result table is not stored — it is recomputed by replaying the last SQL against the restored data, so the view can never disagree with the data; if that SQL no longer runs you get the raw data plus a hint.
A project is not the same as session restore: the session snapshot (settings.json → session) is a few KB and only stores a source reference plus view state, so it breaks the moment the file is gone; a project carries the data with it, which is what you use to deliver, archive or hand over. Opening a project clears the current AI chat and run log (new project, new context) but leaves your UI language and theme alone.
Writes go to a temp file in the same folder and are atomically swapped in, so a crash can't corrupt the previous project. Bad files, missing data and files written by a newer version each produce one clear message instead of a crash. A project file contains your real data — think before sharing it.
Closing asks you to save: if the SQL snippets or the dashboard changed during this session, clicking ✕ first asks Save / Don't save / Cancel. Save writes straight into the current project (or opens Save Project As when there isn't one) and only then quits; a failed save or Cancel keeps the window open.
The top-right panel offers 10 snippet slots by default to stash frequently-used SQL. Use the − / + buttons in the panel header to change the count (1–50); lowering the count only hides slots, stored SQL is never deleted.
- Name: display-only (edited in the popup); names longer than 22 characters are truncated with
…so the buttons stay visible - Edit: popup to set name + SQL, saved on "Save"
- Adopt: one click drops the stored SQL into the editor for you to run (empty slots disabled)
Stored only in the project file (.cioproj meta), no longer in settings.json: Save Project As… packs the slots, Open Project… restores them, so they travel with the project. The trade-off is that slots are gone if you close the app without ever saving a project — save once if you want them to last.
v3.6: tiles draw no border by default — click one to reveal the border plus the
✥drag /✕delete /◢resize affordances. The chart dialog now shows a live preview where you can click a bar or slice to recolor it, and lets you set title alignment, title font/size and table font/size. PPT export loses the card borders and inherits those styles.
The 📊 Dashboard / ← Data toggle at the top-left of the title bar is a single button: click it to switch between the two pages. The original page is now called the Data page (fetch the data); the new one is the Dashboard (look at it).
Switching never loses state. Both pages stay alive in memory; switching only raises the one you want to see. Switch back and your SQL text, result table, column selections, page number and AI conversation are all exactly where you left them — and CioData remembers which page you were on, so a restart lands you back there.
The canvas is locked to 16:9 and scales proportionally, centred, so resizing the window never distorts it. It is divided into 40 × 22 = 880 cells (mid-range of the 500–1000 sweet spot: fine enough to place things precisely, cheap enough to stay smooth). The Show grid checkbox toggles the dashed lines; uncheck it for a clean whiteboard.
Four kinds of tiles, each inserted from the toolbar:
| Tile | Interaction |
|---|---|
+ Chart |
Pick a type, then a PivotChart-style configurator: Axis / Legend / Value (each column with its own aggregation) / Filters / sort / Top N |
+ Table |
A PivotTable-style configurator: row fields (multi-select) / column field / multiple measures with multiple aggregations / Filters / totals on or off |
+ Value |
Absolute number or percentage (a ÷ between two independently configured sides); aggregation is sum / average / max / min / count, with an optional filter |
+ Text |
A free text block (headline / takeaway / footnote); ✨ AI write lets the model read a tile's real numbers and draft the caption; its own font size, and it always stays on top of the charts; with Transparent ticked the card background disappears entirely and the text floats over a chart, the bars showing through between the letters |
Every tile gets a default name on insert (Chart 1 / Table 1 / KPI 1 / Text 1 …, auto-incrementing past duplicates) and it is saved with the layout in settings.json, so it survives a restart and is what the text block's "Based on:" dropdown shows. Double-click a tile to rename it; otherwise the default stays.
Pivot scrollbars are hidden by default — this page is meant to be projected, so the idle state must stay clean. They appear only when rows or columns genuinely do not fit, and disappear again once you enlarge the tile.
Text-block AI captions only read real numbers — and they are audited. Before the model is called, the figures behind the selected tile are distilled into a fact sheet (aggregation, ranked values, extremes with their owner, ties, total); afterwards a deterministic check verifies that every number exists in the sheet, that any "highest / lowest" matches both subject and value, that a sum is not called an average, and that no unit is invented. A failing answer gets one retry with the problems spelled out; if it still fails, a data summary built from the ranking and shares is used instead — contradictory text never reaches you. The text block has no title bar: hold the text to drag, double-click to edit, and it always sits on top — later charts or charts dragged across it never cover it, and the PPT export keeps the same stacking order.
Every column offered in those dialogs is exactly what the Data page is showing right now (SQL result ∩ sidebar selection) and updates live. Uncheck a column on the Data page and it disappears from the dialogs, while existing tiles report "column missing" instead of crashing.
Select, drag, resize. Tiles draw no border by default, keeping the canvas clean; click a tile and it lights up with a 1 px accent border plus three affordances — ✥ (drag, top-left), ✕ (delete, top-right), ◢ (resize, bottom-right). Clicking empty canvas or another tile hides them again. Drag the title bar or ✥; drop positions snap to the grid, so tiles never sit half a cell off. A tile's grid coordinates are the single source of truth; rendering multiplies them by the current scale, which is why layout stays aligned at any window size. Double-click a title to reconfigure.
Value tile filter semantics: comparison operators (equals / greater than / greater-or-equal / less than / less-or-equal / not equal) filter rows first, then aggregate — they do not merely count rows. "Sum of sales where sales > 200" selects the rows above 200, then sums their sales. With the count aggregation you can switch to text matching instead: exact match / contains / does not contain. In percentage mode a zero denominator is reported as an error rather than silently drawn as 100%.
Chart capabilities (everything the old one-click chart did, now inside the canvas):
- Four types: bar / line / pie / scatter
- Multiple measures, multiple aggregations: several Values per chart, each with its own aggregation
- Sort / Top N / Filters: ascending or descending by value, top N only, stackable dimension filters
- Legend grouping: pick a Legend column and the chart splits into series automatically
- Never draws a broken chart: scatter requires numeric axes and says so when you pick a text column; pie uses only the first series and mentions it in the hint
- One colour per data point by default: a single-series bar / pie walks the palette element by element (five bars, five colours), while multiple series take one colour each and rely on the legend. The exported PPT uses the same palette instead of falling back to PowerPoint blue
- Live preview + per-element colors: the dialog paints the real chart and repaints within ~0.1 s of any change; click a bar / slice / line to select it, then use a swatch,
#RRGGBB, or the system picker (single series recolors that element, multiple series recolors the whole series) - Adjustable, draggable labels: numbers above bars and percentages on a pie are drawn by default and can be switched off (size "Auto" = body font − 1, or a pinned 6–18); drag a number or a category name in the preview to move it — bars, lines, pie percentages, pie rim labels and x-axis ticks alike — with a separate Category size for the names; positions are saved with the layout and Reset positions undoes them; the category names themselves can be hidden too (Show categories), and above 40 elements per chart no numbers are drawn — better none than a pile
- Style options: title alignment (left / center / right), title font and size, in-chart text font and size
Layout persistence. Tile positions, sizes and configs (plain JSON, no UI objects) live in settings.json → dashboard_layout and come back on restart. Switching language or theme snapshots and restores the layout too.
The chart button on the Data page is gone: the 📊 Chart button above the results table and its whole callback chain have been removed. Charting now happens on the Dashboard only.
One-click PPT export. ⤓ Export PPT in the toolbar turns the whole canvas into a single 16:9 .pptx slide. Every tile becomes a native PowerPoint object — KPIs and text blocks are text boxes, pivots are real tables, charts are real charts (right-click → Edit Data still works). It is not a screenshot pasted onto the slide, so each card, each label and each bar can be selected, retyped and recoloured individually. Pivot tables that would overflow their card are truncated to the available height with a trailing …. Card backgrounds are exported without borders, and title alignment / font / size plus table font and size carry over. Text blocks are exported without a card background and drawn last, so they never hide the chart underneath. If the target file is already open in PowerPoint you get a friendly "close it and retry" message.
Numbers over 10,000 are abbreviated (1.2K / 1.2M / 1.3B in English, 1.2万 / 1.3亿 in Chinese); large scatter data is evenly sampled with the sample size shown in the hint bar.
Close the app and reopen it — your work is still there. On startup CioData re-reads the last data source, replays the last successfully executed SQL, and restores the SQL editor text, checked columns, page and page size, plus the AI conversation.
- No DataFrame serialization: the snapshot stores only a reference to the data source (path / sheet / row limit) and the view state — a few KB, never a stale copy of 100k rows. If the source file changed on disk, you get the current version.
- Two SQL slots: the text in the editor (even if you edited it without running) and the last SQL that actually produced the result table are kept separately and replayed independently.
- Graceful degradation: a moved/deleted file leaves your SQL and settings intact with a hint; empty files are reported; Databricks is never auto-reconnected (tokens and network are not touched at startup).
- Never overrides you: if you load a file yourself before restore kicks in, restore steps aside. Restore also yields to the Ollama model scan (single background task slot).
- Off switch: set
"restore_session": falseinsettings.json. The snapshot is still written on close, so re-enabling works immediately.
Stored in settings.json → session / restore_session. The snapshot contains local file paths and your SQL/chat text — it stays on your machine and is never uploaded. Only a normal exit (closing the window) writes it; a crash or forced kill leaves the previous snapshot untouched.
A "🧩 Semantic Layer" button sits at the top of the AI panel. Once a YAML is loaded, business definitions come from the config file:
- The LLM no longer writes SQL: it only fills an intent JSON (
metric/filters/time_range/group_by); SQL is 100% compiled deterministically from the YAML by code. - Definitions stay private: the model sees only names + synonyms + descriptions + allowed values;
condition, real column names and time SQL fragments never enter the prompt. - No silent mismatch: if the user asks for a value outside the enum whitelist, the model must emit
__OUT_OF_LIST__— validation fails immediately and falls back instead of substituting a look-alike value. - Value mapping (prefix / grouping): a dimension can define
value_mapto map a logical value to a SQL fragment, e.g.Wave1: wave LIKE 'Wave1%'— asking for Wave1 then matches Wave1.1 / Wave1x. The map never enters the prompt, so the LLM cannot write wildcards itself. - Matched-definition echo: above the compiled SQL you see "Matched: metric=… · wave=… · time=…" so you can verify the system understood you.
- Automatic fallback: no YAML / two failed validations / compile error → Text-to-SQL, with a "Text-to-SQL fallback mode" tag on the bubble.
- Remembers the path: the loaded YAML path is stored in
settings.jsonand reloaded on startup.
A semantic_layer.example.yaml skeleton ships with the app (placeholders only, no invented business data). The old "🧠 Prompts" section (templates / custom rules / advanced system prompt) is gone — put business rules into YAML condition instead.
Switch between "Chat" and "Run Log" with the segmented control at the top of the AI panel. Each question produces one Run with linear, collapsible steps: semantic snapshot → candidate options (the exact option text that goes into the prompt) → build prompt → LLM intent (including the raw model reply) → JSON validation (intent JSON indented) → SQL compilation → read-only check (fallback runs record the trigger and fallback prompt). Click a step to reveal its full input / output; long text stays collapsed but is never truncated.
Cards stream in while the run is still going: each finished step refreshes its card in place, the badge reads "Running" until the run ends (then "SQL compiled" or "Fallback"), and the second header line shows 6 steps · 829 ms — so a stall tells you exactly where it stopped. Steps you expanded stay expanded across those refreshes.
Logs are memory-only — closing the app clears them. Nothing is written to settings.json or disk, and no API keys or tokens are ever recorded.
YAML编辑器.html in the package root opens directly in a browser (Chrome / Edge recommended), fully offline and with no Python dependency. Edit meta / metrics / dimensions / time presets through forms — synonyms and enum values are comma-separated; the YAML preview updates live with instant validation. Open an existing file to keep editing, and save back to the same file (or download if the browser denies direct write). No indentation, brackets or quoting needed.
The "Recent files" dropdown switches between recently opened YAML files (Chrome / Edge remember file permission, so no re-picking is needed; other browsers ask once more). The "🌐 EN / 中文" button switches the UI language on the fly, including the skeleton example — your existing edits are preserved.
Data is deep-copied on load; SQL runs in an isolated in-memory SQLite database; write operations (INSERT/UPDATE/DELETE/DROP…) are blocked at the syntax level; Databricks access is strictly read-only (multi-layer validation + read-only connection); there is no code path that writes back to the original file. Exported CSVs are always brand-new files.
The repo ships two ready-to-open demo datasets (500 rows × 13 columns each: order ID / order date / city / channel / product / category / customer level / unit price / quantity / discount / cost / sales amount / profit):
| File | Language | Generator |
|---|---|---|
| 示例销售数据.xlsx | Chinese | python generate_sample.py |
| sample_sales_data_en.xlsx | English | python generate_sample_en.py |
Load one and ask in plain language, e.g. "top 10 products by profit in Beijing".
| Package | Purpose |
|---|---|
| pandas / numpy | Data processing |
| openpyxl | Read .xlsx |
| requests | LLM API calls |
| customtkinter | Desktop UI |
| Pillow | Image / icon |
| databricks-sql-connector | Databricks (built-in in portable) |
| Ollama (optional external service) | Local model backend |
- README.zh-CN.md — 中文说明 Chinese README
- 使用手册.md — illustrated user manual (Chinese)
- 便携版说明.md — portable build & run guide (Chinese)
- RELEASE_NOTES_v3.6.md — English release notes (ready to paste into a GitHub Release)
- OPEN_SOURCE_STATEMENT.md — open-source statement
- LICENSE — MIT license
CioData/
├── main.py # entry point
├── launcher.py # source launcher (venv + dependency self-check + mirror install)
├── config.py # config center + 4 fixed prompts (intent/fallback, zh+en)
├── settings.py # settings.json persistence
├── session.py # session snapshot validation / source probe / re-read
├── project.py # .cioproj archive: zip(data.csv + layout.json + meta.json), UI-free
├── semantic_layer.py # YAML load / intent validation / deterministic SQL compile
├── i18n.py # zh/en UI strings (390 fully-paired keys)
├── data_loader.py # Excel/CSV/Databricks loading
├── sql_engine.py # in-memory SQLite engine + read-only checks + timeout
├── charting.py # chart engine: column profiling, smart defaults, Figure building
├── dashboard.py # dashboard logic: grid snapping / KPI / pivot / chart series / default names (UI-free)
├── dash_ai.py # text-block AI captions: distill a tile into facts, then ask the model (UI-free)
├── llm_client.py # OpenAI-compatible client + Ollama model scan
├── ui/ # CustomTkinter UI
│ ├── app.py # main window (two-page switch, language-switch rebuild, session/project restore)
│ ├── sidebar.py # left config panel (project / data source / fields / model)
│ ├── workspace.py # SQL editor + results table
│ ├── dashboard_page.py # dashboard: 16:9 canvas + dashed grid + drag/resize + tile host
│ ├── dashboard_dialogs.py # dashboard dialogs: chart / pivot / value / multi-pick (live preview + colors)
│ ├── dash_chart.py # shared chart painter for tiles and preview (per-element colors, value labels)
│ ├── text_overlay.py # overlay for transparent text blocks (Toplevel + colour key, click-through)
│ ├── appicon.py # takes over the title-bar icon (drops customtkinter's logo)
│ ├── chat_panel.py # AI chat + semantic entry + chat/log tabs
│ ├── run_log_view.py # collapsible run-log cards (live refresh, keeps expansion)
│ ├── sql_snippets.py # SQL snippet storage (10 slots by default, adjustable)
│ ├── sql_editor.py # line-numbered highlighted editor
│ ├── data_table.py # paginated sortable table
│ └── ...
├── selfcheck.py # core self-checks (524 items)
├── generate_sample.py # Chinese sample-data generator
├── generate_sample_en.py# English sample-data generator
├── assets/ # logo, sidebar icons (icons/) + README screenshots
├── run.bat # source launcher (Windows)
├── run.sh # source launcher (macOS / Linux)
├── semantic_layer.example.yaml # semantic layer skeleton (shipped)
├── YAML编辑器.html # offline GUI YAML editor
└── install_databricks.bat # one-click Databricks connector installer
Note: the portable launcher
启动 CioData.bat/portable_launcher.pyrelies on the bundledruntime/(several GB) and is distributed only as the GitHub Release attachmentCioData_portable_win64.zip, not as repo content. This repo contains source only and runs on your local Python 3.12 (see "Option B: From Source").
Released under the MIT License (see LICENSE), keeping the "CioData" branding.
You may use, modify, and distribute freely, including commercially, provided the copyright notice, the "CioData" branding, and a link to this statement are retained.
Forks and redistribution are welcome, but modified builds must not be published under the official "CioData" name — suffix your variant (e.g., "YourName (based on CioData)").
- This repository ships source (Python source files + docs + assets) — readable, modifiable, runnable yourself.
- The portable bundle (zip with the embedded Python runtime) is not repo content; it is published only as a GitHub Release binary attachment for users who don't want to install Python.
settings.json(holds API keys / Databricks tokens / the session snapshot) is user-local data and is never committed (excluded in.gitignore).
- The app ships no built-in API keys; all keys are entered by you and stored locally in
settings.json(plain text, local use only). settings.jsonholds API keys, Databricks tokens and the session snapshot (local file paths, SQL text, AI chat text). All of it stays on your machine as plain text; never share or commit it.- Session restore re-reads local files at startup but never reconnects to Databricks or sends any snapshot content to an AI service.
- AI requests send only the column schema (field name + type + sample values) of the columns you select, plus your question text. The data content itself is never uploaded — whether that is acceptable depends on the privacy policy of the AI service you choose.
- Databricks access is strictly read-only (multi-layer validation + connection-level
read_only); your warehouse is never modified. - No telemetry of any kind.
Provided "as is", without warranty of any kind. Validate AI-generated SQL before running it against production data.
Issues and Pull Requests are welcome. Before submitting:
- Keep zh/en copy in sync (
i18n.pypairs zh/en keys one-to-one; currently 226 groups); - Any user-visible string must go through
i18n.t()— no hard-coding; - Follow the existing code style (type hints and Chinese comments are fine).
CioData stands on the shoulders of giants. Thanks to these open-source projects (each under its own license):
| Dependency | Purpose | License |
|---|---|---|
| Python | Runtime | PSF License |
| pandas / numpy | Data processing | BSD |
| openpyxl | Excel read/write | MIT |
| CustomTkinter | Modern Tk UI | MIT |
| Pillow | Image / icon | HPND |
| requests | HTTP client | Apache-2.0 |
| databricks-sql-connector | Databricks | Apache-2.0 |
| Ollama (optional external service) | Local model backend | its own license |
None of these projects re-distribute their source with this repository; copies bundled inside the portable build remain the property of their respective authors, with license texts included.

