harlequin-sqlite-ssh 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. harlequin_sqlite_ssh-0.1.0/.gitignore +169 -0
  2. harlequin_sqlite_ssh-0.1.0/CHANGELOG.md +15 -0
  3. harlequin_sqlite_ssh-0.1.0/LICENSE +21 -0
  4. harlequin_sqlite_ssh-0.1.0/PKG-INFO +164 -0
  5. harlequin_sqlite_ssh-0.1.0/README.md +142 -0
  6. harlequin_sqlite_ssh-0.1.0/docs/en/user-guide.md +364 -0
  7. harlequin_sqlite_ssh-0.1.0/docs/fr/guide-utilisateur.md +391 -0
  8. harlequin_sqlite_ssh-0.1.0/pyproject.toml +132 -0
  9. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/__init__.py +12 -0
  10. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/_agent.py +693 -0
  11. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/adapter.py +362 -0
  12. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/cli_options.py +105 -0
  13. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/errors.py +71 -0
  14. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/locations.py +219 -0
  15. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/py.typed +0 -0
  16. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/remote.py +359 -0
  17. harlequin_sqlite_ssh-0.1.0/src/harlequin_sqlite_ssh/transport.py +723 -0
  18. harlequin_sqlite_ssh-0.1.0/tests/__init__.py +0 -0
  19. harlequin_sqlite_ssh-0.1.0/tests/conftest.py +81 -0
  20. harlequin_sqlite_ssh-0.1.0/tests/fake_ssh_g.py +18 -0
  21. harlequin_sqlite_ssh-0.1.0/tests/test_adapter.py +389 -0
  22. harlequin_sqlite_ssh-0.1.0/tests/test_agent.py +109 -0
  23. harlequin_sqlite_ssh-0.1.0/tests/test_locations.py +133 -0
  24. harlequin_sqlite_ssh-0.1.0/tests/test_remote.py +404 -0
  25. harlequin_sqlite_ssh-0.1.0/tests/test_ssh.py +155 -0
  26. harlequin_sqlite_ssh-0.1.0/tests/test_transport.py +244 -0
@@ -0,0 +1,169 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ Pipfile
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/#use-with-ide
111
+ .pdm.toml
112
+
113
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ #.idea/
162
+
163
+ # Harlequin
164
+ .harlequin.toml
165
+
166
+ # local tooling
167
+ .venv/
168
+ .mypy_cache/
169
+ .ruff_cache/
@@ -0,0 +1,15 @@
1
+ # harlequin-sqlite-ssh CHANGELOG
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.1.0] - 2026-12-02
8
+
9
+ - First release: the `sqlite-ssh` adapter opens SQLite databases on this machine, exactly like Harlequin's own `sqlite` adapter, or on a remote host over SSH (`ssh://[user@]host[:port]/path` or `[user@]host:path`).
10
+ - Remote databases support every feature of the local adapter: queries, catalog, catalog search, completions, read-only mode, connection modes, attached databases, extensions, init scripts, transaction modes, and query cancellation.
11
+ - Adds the `remote-python`, `remote-ssh-option` and `remote-timeout` options, configurable in `harlequin.toml` profiles as `remote_python`, `remote_ssh_option` and `remote_timeout`.
12
+ - Nothing is installed on the remote host: it needs `python3` (3.8 or later) and an SSH server.
13
+
14
+ [unreleased]: https://github.com/lexo13/harlequin-sqlite-ssh/compare/v0.1.0...HEAD
15
+ [0.1.0]: https://github.com/lexo13/harlequin-sqlite-ssh/compare/f8aaf1d26baeda166b3dc609144a1fee848e95e5...v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 lexo13
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.5
2
+ Name: harlequin-sqlite-ssh
3
+ Version: 0.1.0
4
+ Summary: A Harlequin adapter for SQLite databases, on this machine or on remote hosts over SSH.
5
+ Project-URL: Repository, https://github.com/lexo13/harlequin-sqlite-ssh
6
+ Project-URL: Issues, https://github.com/lexo13/harlequin-sqlite-ssh/issues
7
+ Project-URL: Changelog, https://github.com/lexo13/harlequin-sqlite-ssh/blob/main/CHANGELOG.md
8
+ Project-URL: Documentation, https://github.com/lexo13/harlequin-sqlite-ssh/tree/main/docs
9
+ Author: lexo13
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: database,harlequin,sql,sqlite,ssh,tui
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: POSIX
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Topic :: Database :: Front-Ends
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: harlequin<3,>=2.18.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # harlequin-sqlite-ssh
24
+
25
+ A [Harlequin](https://harlequin.sh) adapter for SQLite databases, on this
26
+ machine or on a remote host over SSH.
27
+
28
+ ```bash
29
+ harlequin -a sqlite-ssh ./local.db
30
+ harlequin -a sqlite-ssh ssh://deploy@db.example.com/srv/app/app.db
31
+ harlequin -a sqlite-ssh db.example.com:app/app.db
32
+ ```
33
+
34
+ [Version française](docs/fr/guide-utilisateur.md)
35
+
36
+ ## Why
37
+
38
+ SQLite is a file, not a server: there is no port to connect to, so a database
39
+ that lives on a server is usually copied to your machine before you can open
40
+ it in Harlequin. This adapter opens it where it is instead. It runs `ssh`,
41
+ starts a small agent with the server's own `python3`, and sends your queries
42
+ to it. Nothing is installed or written on the server, and no port is opened.
43
+
44
+ Local databases behave exactly as with Harlequin's built-in `sqlite` adapter:
45
+ this adapter is that adapter, with a remote mode added.
46
+
47
+ ## Features
48
+
49
+ - Local files, `:memory:` and `file:` URIs, exactly as with `-a sqlite`.
50
+ - Remote files over SSH, with every feature of the local adapter: queries,
51
+ data catalog, catalog search, autocompletion, `--read-only`, connection
52
+ modes, attached databases, extensions, init scripts, transaction modes and
53
+ query cancellation.
54
+ - Configuration in `harlequin.toml` profiles, like any other adapter.
55
+ - Works with your `~/.ssh/config`: host aliases, keys, `ProxyJump`,
56
+ `ControlMaster`.
57
+ - Works with `hsql`, Harlequin's non-interactive CLI.
58
+
59
+ ## Requirements
60
+
61
+ - Harlequin 2.18 or later, on Python 3.10 or later.
62
+ - The `ssh` client on your `PATH`.
63
+ - On the remote host: an SSH server, `python3` 3.8 or later with its standard
64
+ `sqlite3` module, and a POSIX shell (sh, bash, zsh, dash...).
65
+ - Authentication that needs no prompt: a key without a passphrase, an
66
+ `ssh-agent`, or an open `ControlMaster` connection. Harlequin owns the
67
+ terminal, so `ssh` cannot ask you for anything.
68
+
69
+ ## Installation
70
+
71
+ With [uv](https://docs.astral.sh/uv/), install Harlequin together with the
72
+ adapter (add your other adapters with more `--with` options):
73
+
74
+ ```bash
75
+ uv tool install harlequin --with harlequin-sqlite-ssh
76
+ ```
77
+
78
+ With pip, in the environment where Harlequin is installed:
79
+
80
+ ```bash
81
+ pip install harlequin-sqlite-ssh
82
+ ```
83
+
84
+ Check that Harlequin sees it: `harlequin --version` lists `sqlite-ssh` among
85
+ the installed adapters.
86
+
87
+ ## Quick start
88
+
89
+ 1. Check that SSH works without a prompt:
90
+
91
+ ```bash
92
+ ssh -o BatchMode=yes deploy@db.example.com python3 --version
93
+ ```
94
+
95
+ 2. Open the database:
96
+
97
+ ```bash
98
+ harlequin -a sqlite-ssh ssh://deploy@db.example.com/srv/app/app.db
99
+ ```
100
+
101
+ 3. Or save it as a profile in `harlequin.toml`:
102
+
103
+ ```toml
104
+ [profiles.app-prod]
105
+ adapter = "sqlite-ssh"
106
+ conn_str = ["ssh://deploy@db.example.com/srv/app/app.db"]
107
+ read_only = true
108
+ ```
109
+
110
+ and run `harlequin -P app-prod`.
111
+
112
+ ## Connection strings
113
+
114
+ | Connection string | Opens |
115
+ |---|---|
116
+ | `app.db`, `/srv/app.db`, `./host:file.db` | a local file |
117
+ | `:memory:`, `file:app.db?mode=ro` | a local in-memory database, a local SQLite URI |
118
+ | `ssh://[user@]host[:port]/srv/app.db` | `/srv/app.db` on `host` |
119
+ | `ssh://host/~/app.db` | `app.db` in the remote home directory |
120
+ | `[user@]host:/srv/app.db` | `/srv/app.db` on `host` (scp style) |
121
+ | `host:app.db` | `app.db` in the remote home directory |
122
+ | `host:file:/srv/app.db?mode=ro` | a SQLite URI, on `host` |
123
+
124
+ `host` may be an alias from `~/.ssh/config`. Several databases can be opened
125
+ in one session (the first is `main`, the others are attached), as long as they
126
+ are all local or all on the same host.
127
+
128
+ ## Options
129
+
130
+ Every option of the `sqlite` adapter works the same way (`--read-only`,
131
+ `--mode`, `--init-path`, `--extension`...). Three options are added:
132
+
133
+ | CLI option | `harlequin.toml` key | Default | Meaning |
134
+ |---|---|---|---|
135
+ | `--remote-python` | `remote_python` | `python3` | The Python to run on the remote host |
136
+ | `--remote-ssh-option` (repeatable) | `remote_ssh_option` (list) | none | `ssh -o` options, e.g. `IdentityFile=~/.ssh/id_db` |
137
+ | `--remote-timeout` | `remote_timeout` | `60` | Seconds to wait for the connection |
138
+
139
+ They are named `remote_*` because Harlequin reserves the `ssh_*` keys for
140
+ its own SSH tunnels, which serve network databases and do not apply here.
141
+
142
+ ## Documentation
143
+
144
+ - [User guide](docs/en/user-guide.md): configuration, authentication,
145
+ security, troubleshooting, and how it works.
146
+ - [Guide utilisateur (français)](docs/fr/guide-utilisateur.md).
147
+
148
+ ## Development
149
+
150
+ ```bash
151
+ uv sync
152
+ make check # ruff, mypy, unit tests
153
+ make e2e # end-to-end tests over ssh to localhost
154
+ make agent-compat # unit tests with the remote agent on Python 3.8
155
+ ```
156
+
157
+ Releasing: run the "Create Release Branch" workflow with the new version,
158
+ merge the pull request it prepares, tag the merge commit `vX.Y.Z`, then run
159
+ `gh workflow run publish.yml --ref main -f tag=vX.Y.Z` and approve the
160
+ `publish` environment.
161
+
162
+ ## License
163
+
164
+ MIT
@@ -0,0 +1,142 @@
1
+ # harlequin-sqlite-ssh
2
+
3
+ A [Harlequin](https://harlequin.sh) adapter for SQLite databases, on this
4
+ machine or on a remote host over SSH.
5
+
6
+ ```bash
7
+ harlequin -a sqlite-ssh ./local.db
8
+ harlequin -a sqlite-ssh ssh://deploy@db.example.com/srv/app/app.db
9
+ harlequin -a sqlite-ssh db.example.com:app/app.db
10
+ ```
11
+
12
+ [Version française](docs/fr/guide-utilisateur.md)
13
+
14
+ ## Why
15
+
16
+ SQLite is a file, not a server: there is no port to connect to, so a database
17
+ that lives on a server is usually copied to your machine before you can open
18
+ it in Harlequin. This adapter opens it where it is instead. It runs `ssh`,
19
+ starts a small agent with the server's own `python3`, and sends your queries
20
+ to it. Nothing is installed or written on the server, and no port is opened.
21
+
22
+ Local databases behave exactly as with Harlequin's built-in `sqlite` adapter:
23
+ this adapter is that adapter, with a remote mode added.
24
+
25
+ ## Features
26
+
27
+ - Local files, `:memory:` and `file:` URIs, exactly as with `-a sqlite`.
28
+ - Remote files over SSH, with every feature of the local adapter: queries,
29
+ data catalog, catalog search, autocompletion, `--read-only`, connection
30
+ modes, attached databases, extensions, init scripts, transaction modes and
31
+ query cancellation.
32
+ - Configuration in `harlequin.toml` profiles, like any other adapter.
33
+ - Works with your `~/.ssh/config`: host aliases, keys, `ProxyJump`,
34
+ `ControlMaster`.
35
+ - Works with `hsql`, Harlequin's non-interactive CLI.
36
+
37
+ ## Requirements
38
+
39
+ - Harlequin 2.18 or later, on Python 3.10 or later.
40
+ - The `ssh` client on your `PATH`.
41
+ - On the remote host: an SSH server, `python3` 3.8 or later with its standard
42
+ `sqlite3` module, and a POSIX shell (sh, bash, zsh, dash...).
43
+ - Authentication that needs no prompt: a key without a passphrase, an
44
+ `ssh-agent`, or an open `ControlMaster` connection. Harlequin owns the
45
+ terminal, so `ssh` cannot ask you for anything.
46
+
47
+ ## Installation
48
+
49
+ With [uv](https://docs.astral.sh/uv/), install Harlequin together with the
50
+ adapter (add your other adapters with more `--with` options):
51
+
52
+ ```bash
53
+ uv tool install harlequin --with harlequin-sqlite-ssh
54
+ ```
55
+
56
+ With pip, in the environment where Harlequin is installed:
57
+
58
+ ```bash
59
+ pip install harlequin-sqlite-ssh
60
+ ```
61
+
62
+ Check that Harlequin sees it: `harlequin --version` lists `sqlite-ssh` among
63
+ the installed adapters.
64
+
65
+ ## Quick start
66
+
67
+ 1. Check that SSH works without a prompt:
68
+
69
+ ```bash
70
+ ssh -o BatchMode=yes deploy@db.example.com python3 --version
71
+ ```
72
+
73
+ 2. Open the database:
74
+
75
+ ```bash
76
+ harlequin -a sqlite-ssh ssh://deploy@db.example.com/srv/app/app.db
77
+ ```
78
+
79
+ 3. Or save it as a profile in `harlequin.toml`:
80
+
81
+ ```toml
82
+ [profiles.app-prod]
83
+ adapter = "sqlite-ssh"
84
+ conn_str = ["ssh://deploy@db.example.com/srv/app/app.db"]
85
+ read_only = true
86
+ ```
87
+
88
+ and run `harlequin -P app-prod`.
89
+
90
+ ## Connection strings
91
+
92
+ | Connection string | Opens |
93
+ |---|---|
94
+ | `app.db`, `/srv/app.db`, `./host:file.db` | a local file |
95
+ | `:memory:`, `file:app.db?mode=ro` | a local in-memory database, a local SQLite URI |
96
+ | `ssh://[user@]host[:port]/srv/app.db` | `/srv/app.db` on `host` |
97
+ | `ssh://host/~/app.db` | `app.db` in the remote home directory |
98
+ | `[user@]host:/srv/app.db` | `/srv/app.db` on `host` (scp style) |
99
+ | `host:app.db` | `app.db` in the remote home directory |
100
+ | `host:file:/srv/app.db?mode=ro` | a SQLite URI, on `host` |
101
+
102
+ `host` may be an alias from `~/.ssh/config`. Several databases can be opened
103
+ in one session (the first is `main`, the others are attached), as long as they
104
+ are all local or all on the same host.
105
+
106
+ ## Options
107
+
108
+ Every option of the `sqlite` adapter works the same way (`--read-only`,
109
+ `--mode`, `--init-path`, `--extension`...). Three options are added:
110
+
111
+ | CLI option | `harlequin.toml` key | Default | Meaning |
112
+ |---|---|---|---|
113
+ | `--remote-python` | `remote_python` | `python3` | The Python to run on the remote host |
114
+ | `--remote-ssh-option` (repeatable) | `remote_ssh_option` (list) | none | `ssh -o` options, e.g. `IdentityFile=~/.ssh/id_db` |
115
+ | `--remote-timeout` | `remote_timeout` | `60` | Seconds to wait for the connection |
116
+
117
+ They are named `remote_*` because Harlequin reserves the `ssh_*` keys for
118
+ its own SSH tunnels, which serve network databases and do not apply here.
119
+
120
+ ## Documentation
121
+
122
+ - [User guide](docs/en/user-guide.md): configuration, authentication,
123
+ security, troubleshooting, and how it works.
124
+ - [Guide utilisateur (français)](docs/fr/guide-utilisateur.md).
125
+
126
+ ## Development
127
+
128
+ ```bash
129
+ uv sync
130
+ make check # ruff, mypy, unit tests
131
+ make e2e # end-to-end tests over ssh to localhost
132
+ make agent-compat # unit tests with the remote agent on Python 3.8
133
+ ```
134
+
135
+ Releasing: run the "Create Release Branch" workflow with the new version,
136
+ merge the pull request it prepares, tag the merge commit `vX.Y.Z`, then run
137
+ `gh workflow run publish.yml --ref main -f tag=vX.Y.Z` and approve the
138
+ `publish` environment.
139
+
140
+ ## License
141
+
142
+ MIT