Skip to main content

SQLite REPL written in python3

Project description

# SQLite REPL written in Python3

## Good completion

![](screens/6.png)

![](screens/1.png)

![](screens/2.png)

![](screens/3.png)

![](screens/7.png)

![](screens/8.png)

![](screens/9.png)

![](screens/10.png)

```
usage: SQLiteREPL [-h] [-H [PATH]] [-e [FILE]] [-m] [-v] [-M]
[--no-history-search] [--no-complete-while-typing]
[--no-infobar] [--no-editor] [-t STYLE] [-s STYLE]
[-p STRING]
[database]

A dead simple REPL for SQLite

positional arguments:
database path to database

optional arguments:
-h, --help show this help message and exit
-H [PATH], --history [PATH]
path to history file
-e [FILE], --eval [FILE]
eval SQL script before running the REPL
-m, --multiline enable multiline mode (useful for creating tables)
-v, --verbose enable verbose logging
-M, --memory in memory database
--no-history-search disable history search
--no-complete-while-typing
disable completion while typing
--no-infobar disable info bar at the bottom of the screen
--no-editor disable opening in $EDITOR
-t STYLE, --table_style STYLE
set table style to <STYLE>, (see
https://pypi.org/project/tabulate/) (hint: try
"simple", "orgtbl", "pipe", "html" or "latex")
-s STYLE, --style STYLE
pygments style (see
http://pygments.org/docs/styles/#builtin-styles)
-p STRING, --prompt STRING
prompt string
```

## Modify REPL whilst it's running

The following `.meta` commands are supported:

```
.dump [FILE] Stringify database into SQL commands or STDOUT if FILE is not provided.
.exit Exit the REPL.
.help [PATTERN] Display meta commands matching PATTERN or ALL if PATTERN is not provided.
.mode [STYLE] Change table style to STYLE or display current style if STYLE is not provided.
.open [DATABASE] Close this database and open DATABASE or show current database if DATABASE is not provided.
.output [FILE] Redirect output of commands to FILE (or to STDOUT if FILE == "stdout"), shows current output stream if FILE is not provided.
.print [STRING, ...] Display given STRING in the terminal.
.prompt [STRING] Change prompt to STRING.
.quit Exit the REPL.
.read [FILE] Eval SQL from FILE.
.save <FILE> Save in-memory database to FILE.
.schema [PATTERN] Show schemas for tables in the database matching PATTERN.
.shell <CMD> [ARG, ...] Run an OS command CMD.
.show [PATTERN] Display info about the REPL starting with PATTERN or all info if PATTERN is not provided.
.style [STYLE] Change style to STYLE or show current style if STYLE is not provided.
.system <CMD> [ARG, ...] Run an OS command CMD with ARGS.
.tables [PATTERN] Show tables in the database matching PATTERN or show all tables if PATTERN is not provided.
```

**NOTE**:

These are actually a subset of what the official sqlite3 REPL supports. The syntax is kept similar.

**NOTE**:

unless you specify the database location with database, it will be
loaded in memory.

## Customisation

- check out pygments for all the possible styles
- check out tabulate for all the table types
- use aliases for "semi-permanent" config e.g.: `alias sqlite='sqliterepl --multiline'`

## Compatibility

It should work on Win10 and Linux.

## Installation

```sh
$ pip install --user 'git+https://github.com/nl253/SQLiteREPL@master'
```

## Limitations

- not context sensitive
- doesn't complete table names
- no table headings

## Dependencies

- [prompt-toolkit](https://github.com/jonathanslenders/python-prompt-toolkit)
- [tabulate](https://pypi.org/project/tabulate/)
- Python >= 3.7

**Note**:

SQLiteREPL has been updated to use `prompt_toolkit 2`.

## Related

- <https://github.com/dbcli/mycli>



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqliterepl-2.0.0a1.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqliterepl-2.0.0a1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file sqliterepl-2.0.0a1.tar.gz.

File metadata

  • Download URL: sqliterepl-2.0.0a1.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

File hashes

Hashes for sqliterepl-2.0.0a1.tar.gz
Algorithm Hash digest
SHA256 2ee613f1772f04421bab5572b3a29526959f7f61a539c10ba8eeac53d29290df
MD5 1f47f013fb9a9875d008c529051ecadf
BLAKE2b-256 fb9816080b668b1dc7a3690dadad26e45ea5597c14dbe7ef5c7b6d3bbb3879e3

See more details on using hashes here.

File details

Details for the file sqliterepl-2.0.0a1-py3-none-any.whl.

File metadata

  • Download URL: sqliterepl-2.0.0a1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

File hashes

Hashes for sqliterepl-2.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6bf8ce70663a018289d1e19c2e7140699848215ab195e5ba1ae9b04573c9d26
MD5 6edf204a18562d5261f12c5a74d56cb0
BLAKE2b-256 6d4e7f123f9f21de03adacb30accf8eb38f5f828aa577e37e6f34b654636e6d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page