如何打开Python3安装的sqlite3?

如何打开Python3安装的sqlite3?,python,python-3.x,sqlite,Python,Python 3.x,Sqlite,Ubuntu python2和python3都可以导入sqlite3,但我不能在命令提示符中键入sqlite3来打开它,它说sqlite3没有安装,如果我想在python之外使用它,我应该单独使用apt get来安装sqlite3,还是可以在python的某个目录中找到它,将它添加到path中并直接在命令行中使用 我还在mac上安装了python3.5,这是python2附带的mac,我可以在命令行中按类型sqlite3使用sqlite3,它是版本3.8.10.2,似乎是由python2安装的,

Ubuntu python2和python3都可以导入sqlite3,但我不能在命令提示符中键入
sqlite3
来打开它,它说sqlite3没有安装,如果我想在python之外使用它,我应该单独使用apt get来安装sqlite3,还是可以在python的某个目录中找到它,将它添加到path中并直接在命令行中使用


我还在mac上安装了python3.5,这是python2附带的mac,我可以在命令行中按类型
sqlite3
使用sqlite3,它是版本3.8.10.2,似乎是由python2安装的,但是python3.5安装了不同版本的sqlite3,我在哪里可以找到它?

在python上使用sqlite3不需要安装任何东西

关于sqlite:

如果您有使用数据库的经验, 您可以认为sqlite3是一个类似于数据库包含表的文件

因为python支持sqlite3,所以可以创建一个新的sqlite3文件

此示例仅使用python创建一个新的example.db文件(如果不存在)

import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()

# Create table
c.execute('''CREATE TABLE stocks
             (date text, trans text, symbol text, qty real, price real)''')

# Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")

# Save (commit) the changes
conn.commit()

# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
阅读本文件:

但我建议您安装sqlite以使用sqlite的命令行Shell

$ sqlite3 ex1
SQLite version 3.8.5 2014-05-29 12:36:14
Enter ".help" for usage hints.
sqlite> create table tbl1(one varchar(10), two smallint);
sqlite> insert into tbl1 values('hello!',10);
sqlite> insert into tbl1 values('goodbye', 20);
sqlite> select * from tbl1;
hello!|10
goodbye|20
sqlite>

在python上使用sqlite3不需要安装任何东西

关于sqlite:

如果您有使用数据库的经验, 您可以认为sqlite3是一个类似于数据库包含表的文件

因为python支持sqlite3,所以可以创建一个新的sqlite3文件

此示例仅使用python创建一个新的example.db文件(如果不存在)

import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()

# Create table
c.execute('''CREATE TABLE stocks
             (date text, trans text, symbol text, qty real, price real)''')

# Insert a row of data
c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")

# Save (commit) the changes
conn.commit()

# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
阅读本文件:

但我建议您安装sqlite以使用sqlite的命令行Shell

$ sqlite3 ex1
SQLite version 3.8.5 2014-05-29 12:36:14
Enter ".help" for usage hints.
sqlite> create table tbl1(one varchar(10), two smallint);
sqlite> insert into tbl1 values('hello!',10);
sqlite> insert into tbl1 values('goodbye', 20);
sqlite> select * from tbl1;
hello!|10
goodbye|20
sqlite>

正如Robert Moon所说,自2.5版开始,Python中就包含sqlite3,您可以直接使用它。请看他的帖子以获得一个示例

Sqlite是一个管理存储在文件中的SQL数据库的库。因此,在软件或网站中使用它很容易,您可以使用一种语言向数据库(存储在文件中)发出请求

如果您想在python脚本之外使用sqlite3,那么必须在Ubuntu中安装该软件包

sudo apt-get install sqlite3
然后可以运行sqlite终端

sqlite3

要发出请求、创建新数据库等等。

正如Robert Moon所说,sqlite3自2.5版以来就包含在Python中,您可以直接使用它。请看他的帖子以获得一个示例

Sqlite是一个管理存储在文件中的SQL数据库的库。因此,在软件或网站中使用它很容易,您可以使用一种语言向数据库(存储在文件中)发出请求

如果您想在python脚本之外使用sqlite3,那么必须在Ubuntu中安装该软件包

sudo apt-get install sqlite3
然后可以运行sqlite终端

sqlite3

要发出请求,请创建新数据库等。

任何在此处找到自己的Cygwin用户:运行Cygwin安装.exe


选择“类别”、“数据库”,然后其中一项显示“sqlite3客户端访问sqlite3数据库”,或类似的文字。

任何在此处找到自己的Cygwin用户:运行Cygwin安装.exe

选择“Categories”、“Database”,然后有一项显示“sqlite3 client to access sqlite3 databases”,或类似的词语