macos 在 Mac OSX 上安装 SQLite - 或者,是否有推荐的备用数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4972882/
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:42:04  来源:igfitidea点击:

Installing SQLite On Mac OSX - Or, Is There A Recommended Alternate DB?

macossqlite

提问by headscratch

I'd like some advice on SQLite in OSX Snow Leopard.

我想要一些关于 OSX Snow Leopard 中 SQLite 的建议。

I've read a gazillion posts and, of course, nearly all tell of the problems, and not the solution. Before attempting an install that may lead to problems, I'd like to get the "Here's how to do it" that works.

我读过无数帖子,当然,几乎所有帖子都讲述了问题,而不是解决方案。在尝试可能会导致问题的安装之前,我想先了解一下有效的“这是如何操作

I do have MySQL installed and can use it in Netbeans.

我确实安装了 MySQL 并且可以在 Netbeans 中使用它。

I also use SQLite as part of my Android app programming (via Eclipse).

我还使用 SQLite 作为我的 Android 应用程序编程的一部分(通过 Eclipse)。

I also use the database that comes with Netbeans/java but, it requires going through lot's of hoops to run it outside the NB IDE.

我也使用 Netbeans/java 附带的数据库,但是,它需要经过大量的工作才能在 NB IDE 之外运行它。

I also use Base (the OpenOffice database).

我也使用 Base(OpenOffice 数据库)。

Although I can easily turn on/off MySQL from the convenient add-on to the Sys Pref's, it is a memory hog and memory isn't released after turning off the connection and turning it off. Also, I don't really need it's power for my minimal db needs so, I'd like to use a smaller footprint, such as SQLite.

虽然我可以通过 Sys Pref 的方便附加组件轻松打开/关闭 MySQL,但它是一个内存占用,并且在关闭连接并将其关闭后不会释放内存。另外,我真的不需要它来满足我最小的数据库需求,所以我想使用更小的空间,比如 SQLite。

Some Questions:

一些问题

  1. Since I use SQLite with Android, is it available to use in standard Java from Eclipse ?How about from Netbeans ?(I prefer Netbeans for standard java programming). And, how to run it outside Eclipse/Netbeans IDE ?.

  2. Where can I find the Simplest install instructions ?

  3. Is there a GUI interface available that enables basic db create/query...etc (What and where to find it ?). Perhaps even a tutorial... I'd like to be able to work with a database as a stand-alone rather than through a cumbersome IDE.

  4. Is there an alternate stand-alone ?
  1. 由于我将 SQLite 与 Android 一起使用,是否可以在 Eclipse 的标准 Java 中使用它来自 Netbeans怎么样?(我更喜欢 Netbeans 进行标准 Java 编程)。而且,如何在 Eclipse/Netbeans IDE 之外运行它.

  2. 我在哪里可以找到最简单的安装说明

  3. 是否有可用的 GUI 界面来启用基本的数据库创建/查询...等(什么以及在哪里可以找到它)。甚至可能是一个教程......我希望能够将数据库作为独立的工作,而不是通过繁琐的 IDE。

  4. 有替代的单机吗?

Thanks - any input is much appreciated.

谢谢 - 非常感谢任何输入。

采纳答案by Laurent Bourgault-Roy

First, sorry if you already knew that : SQlite is an embedded database, which mean it is only a file somewhere on the filesystem. All you need to use a SQLite database is a language with a database connector that will convert your SQL statement in read/write in the file format. So their is no "install" per say, except maybe to create a file somewhere . And even then, connecting to an existing file will create it for you in most library! And it will not use memory, since all the operation are executed inside your app. (EDIT well it will increase the memory footprint of your app, of course)

首先,抱歉,如果您已经知道:SQlite 是一个嵌入式数据库,这意味着它只是文件系统上某处的一个文件。使用 SQLite 数据库所需的只是一种带有数据库连接器的语言,该连接器可以将您的 SQL 语句以文件格式进行读/写转换。所以他们不是说“安装”,除了可能在某处创建一个文件。即便如此,连接到现有文件将在大多数库中为您创建它!它不会使用内存,因为所有操作都在您的应用程序内执行。(编辑好它会增加你的应用程序的内存占用,当然)

Of course, the downside is that only program on the same machine can connect on the database.

当然,缺点是只有同一台机器上的程序才能连接数据库。

So to answer your questions.

所以来回答你的问题。

1- Yes, you can use SQlite from standard Java. You just need to use a JDBC driver. Here is one http://www.zentus.com/sqlitejdbc/that is fully managed (it run entirely in the java VM)

1- 是的,您可以使用标准 Java 中的 SQlite。您只需要使用 JDBC 驱动程序。这是一个完全托管的http://www.zentus.com/sqlitejdbc/(它完全在 Java VM 中运行)

2- Connect a file somewhere on your computer. If it doesn't exist, it will create it for you. If you do that, you will then need to create your table in your code. I don't how much simpler it can get to be honest. The JDBC driver is installed like any other. You can also create the file manually with a GUI editor if you wish.

2- 将文件连接到计算机上的某个位置。如果它不存在,它将为您创建它。如果这样做,则需要在代码中创建表。老实说,我不知道它可以变得多么简单。JDBC 驱动程序的安装方式与其他驱动程序一样。如果您愿意,也可以使用 GUI 编辑器手动创建文件。

3- I haven't found a SQLite plugin in the official plug-in list of Netbeans, but I have found this http://netbeans.dzone.com/announcements/sqlite-jdbc-driver-plugin, which seem to be very, very beta, so I would be cautious before using is.

3-我在Netbeans的官方插件列表中没有找到SQLite插件,但是我找到了这个http://netbeans.dzone.com/announcements/sqlite-jdbc-driver-plugin,看起来很,非常测试版,所以在使用之前我会谨慎。

4- Since I always use SQlite purely in code, I can't recommend any GUI tool in particular. Other people may know more. There is this http://saxmike.com/MySoftware/MySoftware.asp?Menu=MYSOFTWARE, but the page has an animated gift, so...

4- 因为我总是纯粹在代码中使用 SQlite,所以我不能特别推荐任何 GUI 工具。其他人可能知道更多。有这个http://saxmike.com/MySoftware/MySoftware.asp?Menu=MYSOFTWARE,但页面有一个动画礼物,所以......

Good luck with all that!

祝你一切顺利!

回答by stewart715

Terminal:

终端:

 curl -O http://www.sqlite.org/sqlite-3.3.6.tar.gz
 tar xzvf ./sqlite-3.3.6.tar.gz
 cd sqlite-3.3.6
 ./configure --prefix=/usr/local
 make
 sudo make install