Name | claude-to-sqlite JSON |
Version |
0.2
JSON |
| download |
home_page | None |
Summary | Convert a Claude.ai export to SQLite |
upload_time | 2024-10-21 03:06:13 |
maintainer | None |
docs_url | None |
author | Simon Willison |
requires_python | >=3.8 |
license | Apache-2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# claude-to-sqlite
[![PyPI](https://img.shields.io/pypi/v/claude-to-sqlite.svg)](https://pypi.org/project/claude-to-sqlite/)
[![Changelog](https://img.shields.io/github/v/release/simonw/claude-to-sqlite?include_prereleases&label=changelog)](https://github.com/simonw/claude-to-sqlite/releases)
[![Tests](https://github.com/simonw/claude-to-sqlite/actions/workflows/test.yml/badge.svg)](https://github.com/simonw/claude-to-sqlite/actions/workflows/test.yml)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/claude-to-sqlite/blob/master/LICENSE)
Convert a [Claude.ai](https://claude.ai/) export to SQLite
## Installation
Install this tool using `pip`:
```bash
pip install claude-to-sqlite
```
## Usage
Start by [exporting your Claude data](https://support.anthropic.com/en/articles/9450526-how-can-i-export-my-claude-ai-data). You will be emailed a link to a zip file (though it may be missing the `.zip` extension).
Run the command like this:
```bash
claude-to-sqlite claude-export.zip claude.db
```
Now `claude.db` will be a SQLite containing the `conversations` and `messages` from your Claude export.
You can explore that using [Datasette](https://datasette.io/):
```bash
datasette claude.db
```
## Database schema
Assuming the Claude export JSON has not changed since this tool was last released on 20th October 2024 the database tables should look like this:
<!-- [[[cog
import tempfile, pathlib, sqlite_utils
from click.testing import CliRunner
from claude_to_sqlite import cli
tmpdir = pathlib.Path(tempfile.mkdtemp())
db_path = str(tmpdir / "claude.db")
runner = CliRunner()
runner.invoke(cli.cli, ["tests/artifacts.json", db_path])
cog.out("```sql\n")
schema = sqlite_utils.Database(db_path).schema
cog.out(schema)
cog.out("\n```")
]]] -->
```sql
CREATE TABLE [conversations] (
[uuid] TEXT PRIMARY KEY,
[name] TEXT,
[created_at] TEXT,
[updated_at] TEXT,
[account_id] TEXT
);
CREATE TABLE [messages] (
[uuid] TEXT PRIMARY KEY,
[text] TEXT,
[sender] TEXT,
[created_at] TEXT,
[updated_at] TEXT,
[attachments] TEXT,
[files] TEXT,
[conversation_id] TEXT REFERENCES [conversations]([uuid])
);
CREATE TABLE [artifacts] (
[id] TEXT PRIMARY KEY,
[artifact] TEXT,
[identifier] TEXT,
[version] INTEGER,
[type] TEXT,
[language] TEXT,
[title] TEXT,
[content] TEXT,
[thinking] TEXT,
[conversation_id] TEXT REFERENCES [conversations]([uuid]),
[message_id] TEXT REFERENCES [messages]([uuid])
);
```
<!-- [[[end]]] -->
## Development
To contribute to this tool, first checkout the code. Then create a new virtual environment:
```bash
cd claude-to-sqlite
python -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
python -m pytest
```
Raw data
{
"_id": null,
"home_page": null,
"name": "claude-to-sqlite",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Simon Willison",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/aa/e1/53799e8f3240ff08d6aa8cf1c86f4322148dc6dc0bc3b7776f8c82695291/claude_to_sqlite-0.2.tar.gz",
"platform": null,
"description": "# claude-to-sqlite\n\n[![PyPI](https://img.shields.io/pypi/v/claude-to-sqlite.svg)](https://pypi.org/project/claude-to-sqlite/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/claude-to-sqlite?include_prereleases&label=changelog)](https://github.com/simonw/claude-to-sqlite/releases)\n[![Tests](https://github.com/simonw/claude-to-sqlite/actions/workflows/test.yml/badge.svg)](https://github.com/simonw/claude-to-sqlite/actions/workflows/test.yml)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/claude-to-sqlite/blob/master/LICENSE)\n\nConvert a [Claude.ai](https://claude.ai/) export to SQLite\n\n## Installation\n\nInstall this tool using `pip`:\n```bash\npip install claude-to-sqlite\n```\n## Usage\n\nStart by [exporting your Claude data](https://support.anthropic.com/en/articles/9450526-how-can-i-export-my-claude-ai-data). You will be emailed a link to a zip file (though it may be missing the `.zip` extension).\n\nRun the command like this:\n\n```bash\nclaude-to-sqlite claude-export.zip claude.db\n```\nNow `claude.db` will be a SQLite containing the `conversations` and `messages` from your Claude export.\n\nYou can explore that using [Datasette](https://datasette.io/):\n\n```bash\ndatasette claude.db\n```\n## Database schema\n\nAssuming the Claude export JSON has not changed since this tool was last released on 20th October 2024 the database tables should look like this:\n\n<!-- [[[cog\nimport tempfile, pathlib, sqlite_utils\nfrom click.testing import CliRunner\nfrom claude_to_sqlite import cli\n\ntmpdir = pathlib.Path(tempfile.mkdtemp())\ndb_path = str(tmpdir / \"claude.db\")\nrunner = CliRunner()\nrunner.invoke(cli.cli, [\"tests/artifacts.json\", db_path])\ncog.out(\"```sql\\n\")\nschema = sqlite_utils.Database(db_path).schema\ncog.out(schema)\ncog.out(\"\\n```\")\n]]] -->\n```sql\nCREATE TABLE [conversations] (\n [uuid] TEXT PRIMARY KEY,\n [name] TEXT,\n [created_at] TEXT,\n [updated_at] TEXT,\n [account_id] TEXT\n);\nCREATE TABLE [messages] (\n [uuid] TEXT PRIMARY KEY,\n [text] TEXT,\n [sender] TEXT,\n [created_at] TEXT,\n [updated_at] TEXT,\n [attachments] TEXT,\n [files] TEXT,\n [conversation_id] TEXT REFERENCES [conversations]([uuid])\n);\nCREATE TABLE [artifacts] (\n [id] TEXT PRIMARY KEY,\n [artifact] TEXT,\n [identifier] TEXT,\n [version] INTEGER,\n [type] TEXT,\n [language] TEXT,\n [title] TEXT,\n [content] TEXT,\n [thinking] TEXT,\n [conversation_id] TEXT REFERENCES [conversations]([uuid]),\n [message_id] TEXT REFERENCES [messages]([uuid])\n);\n```\n<!-- [[[end]]] -->\n\n## Development\n\nTo contribute to this tool, first checkout the code. Then create a new virtual environment:\n```bash\ncd claude-to-sqlite\npython -m venv venv\nsource venv/bin/activate\n```\nNow install the dependencies and test dependencies:\n```bash\npip install -e '.[test]'\n```\nTo run the tests:\n```bash\npython -m pytest\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Convert a Claude.ai export to SQLite",
"version": "0.2",
"project_urls": {
"CI": "https://github.com/simonw/claude-to-sqlite/actions",
"Changelog": "https://github.com/simonw/claude-to-sqlite/releases",
"Homepage": "https://github.com/simonw/claude-to-sqlite",
"Issues": "https://github.com/simonw/claude-to-sqlite/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "aa6578270e19a9454730b27373b1a19f5e86524d3a9e4b3ed06cdb5ca17264b2",
"md5": "87bf77bbe944891c52e407ee24104e5f",
"sha256": "75440f745f47bfec96b84f23413a701a69c87ac35de205bfc8680b1869abde96"
},
"downloads": -1,
"filename": "claude_to_sqlite-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "87bf77bbe944891c52e407ee24104e5f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8943,
"upload_time": "2024-10-21T03:06:12",
"upload_time_iso_8601": "2024-10-21T03:06:12.524377Z",
"url": "https://files.pythonhosted.org/packages/aa/65/78270e19a9454730b27373b1a19f5e86524d3a9e4b3ed06cdb5ca17264b2/claude_to_sqlite-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aae153799e8f3240ff08d6aa8cf1c86f4322148dc6dc0bc3b7776f8c82695291",
"md5": "ba5a53896d23a9e46148aa7447c7ce3c",
"sha256": "98927612aea38c40d93368d2cd54b32e11b24fe93eb8550c9e6ec031d1134c5e"
},
"downloads": -1,
"filename": "claude_to_sqlite-0.2.tar.gz",
"has_sig": false,
"md5_digest": "ba5a53896d23a9e46148aa7447c7ce3c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9444,
"upload_time": "2024-10-21T03:06:13",
"upload_time_iso_8601": "2024-10-21T03:06:13.478653Z",
"url": "https://files.pythonhosted.org/packages/aa/e1/53799e8f3240ff08d6aa8cf1c86f4322148dc6dc0bc3b7776f8c82695291/claude_to_sqlite-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-21 03:06:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simonw",
"github_project": "claude-to-sqlite",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "claude-to-sqlite"
}