Search code examples
sqlitecommand-line-interfacepaste

Can't paste over 255 characters into SQLite CLI


I'm a Python/SQLite/Tkinter hobbyist, full-time for 6 years, and this has never happened before. But I recently started using a new version of the SQLite CLI and this might be the first time I tried to paste over 255 characters since the change.

I tried pasting the same clipboard contents into my editor, no problem, and into the same CMD version when it's not running the SQLite tool, also no problem. Same story with Powershell.

Here's what I copied with CTRL-C:

CREATE TABLE repositories_links (repositories_links_id INTEGER PRIMARY KEY, repository_type_id INTEGER DEFAULT null, source_id INTEGER DEFAULT null, citation_id INTEGER DEFAULT null, repository_id INTEGER DEFAULT null, locator_id INTEGER DEFAULT null, media_id INTEGER DEFAULT null, contact_id INTEGER DEFAULT null, FOREIGN KEY (repository_type_id) REFERENCES repository_type (repository_type_id), FOREIGN KEY (source_id) REFERENCES source (source_id), FOREIGN KEY (citation_id) REFERENCES citation (citation_id), FOREIGN KEY (repository_id) REFERENCES repository (repository_id), FOREIGN KEY (locator_id) REFERENCES locator (locator_id), FOREIGN KEY (media_id) REFERENCES media (media_id), FOREIGN KEY (contact_id) REFERENCES contact (contact_id));

And here's all that gets pasted into the SQLite CLI:

sqlite> CREATE TABLE repositories_links (repositories_links_id INTEGER PRIMARY KEY, repository_type_id INTEGER DEFAULT null, source_id INTEGER DEFAULT null, citation_id INTEGER DEFAULT null, repository_id INTEGER DEFAULT null, locator_id INTEGER DEFAULT null, me

I tried restarting the SQLite CLI, tried googling the problem but there are so many references to 255 chars to wade through. Maybe someone could tell me where to start, I'm not a real programmer and don't know much about Windows.

I'm using Windows 11 on a 64-bit machine. Here's the version info on the SQLite tool:

SQLite version 3.45.1 2024-01-30 16:01:20 (UTF-16 console I/O)

Before this I used an older version of SQLite for years and never had a problem like this, on this or any other computer.

I don't normally paste things into SQLite but it saves typing when SQLite makes me recreate a whole table just to delete some columns, and I do a lot of schema adjustments. SQLite has never let me down before.


Solution

  • Here is the best workaround, as suggested here by Warren Young. Posts at this source also explain technically why this problem is not being caused by anything SQLite is doing.

    Windows has three CLI tools: cmd.exe, Powershell and the one I'd forgotten about because of its bad behavior: Terminal.

    Terminal is the best solution because I can paste the whole SQLite create table command, the whole thing displays, I can edit it, and when I press Enter the command runs as expected. This no longer works in cmd.exe or Powershell on my up-to-date Windows 11.

    The reason I'd purposely forgotten that Terminal exists is that you have to resize the window before you type into it, for example if you're going to try and display a large table. Unlike the newer versions of cmd.exe, you can't redisplay the contents of the previous output, stretched across the larger resized window, by manually resizing the window. Worse than that, after making the window wider, the command line (starts with sqlite>) stays where it's supposed to be but anything you type into it displays up in among the previous output. You can keep typing, the commands will work, but to make it display right you have to close the tab and start over in a new tab. And remember to resize the window before you type anything.

    Nevertheless, using Terminal for this one SQLite task--editing long schemas, which I do when I need to remove columns from an existing table--is the best workaround.