macos 从终端 Mac 编辑 sqlite 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5180895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:47:02  来源:igfitidea点击:

Edit sqlite file from terminal Mac

macossqliteterminal

提问by LuckyLuke

I can not find any documents where I can open existing sqlite database file that I made from the terminal on Mac. I want to add some additional rows to the existing database. I probably search for the wrong things, so anything that points me in the right direction is much appriciated.

我找不到任何可以打开从 Mac 终端创建的现有 sqlite 数据库文件的文档。我想向现有数据库添加一些额外的行。我可能会寻找错误的东西,因此任何为我指明正确方向的东西都非常受欢迎。

回答by Greg Glockner

If you want to remain in the Terminal, you can open a sqlite3 database using the command sqlite3 [databasename]. From here, you can select rows or insert new ones using SQL commands. If you prefer a GUI, there are many to choose from, including the free Firefox plugin, sqlite-manager.

如果你想留在终端中,你可以使用命令打开一个 sqlite3 数据库sqlite3 [databasename]。从这里,您可以使用 SQL 命令选择行或插入新行。如果您更喜欢 GUI,有很多可供选择,包括免费的 Firefox 插件sqlite-manager

回答by Kex

Whenever you work with Mac built-in sqlite3 it saves the files in the current folder where your Terminal is and the way you can access them is the reversed story, open sqlite3 while you are at the folder where your database is.

每当您使用 Mac 内置的 sqlite3 时,它都会将文件保存在终端所在的当前文件夹中,而您访问它们的方式则相反,在您位于数据库所在的文件夹时打开 sqlite3。

回答by pluckyglen

I realize this is a bit tangential to the question, but it's helpful to be able to find/move hidden files in Finder, because often sqlite DBs will wind up in a hidden folder. See:

我意识到这与问题有点无关,但是能够在 Finder 中查找/移动隐藏文件是有帮助的,因为通常 sqlite DB 会出现在隐藏文件夹中。看:

http://www.macworld.com/article/1051830/showallfinder.html

http://www.macworld.com/article/1051830/showallfinder.html

The key bit is to enter this in the Terminal, then force Finder to relaunch (via the Apple menu's Force Quit on Lion):

关键是在终端中输入这个,然后强制 Finder 重新启动(通过 Apple 菜单的强制退出 Lion):

defaults write com.apple.Finder AppleShowAllFiles YES

Change that to NO at the end to toggle it off.

最后将其更改为 NO 以将其关闭。