SQLite is a database engine that makes it simple to store and work with relational data. Much like the csv format, SQLite stores data in a single file that can be easily shared with others. Most programming languages and environments have good support for working with SQLite databases. Python is no exception, and a library to access SQLite databases, called sqlite3
, has been included with Python since version 2.5
. In this post, we’ll walk through how to use sqlite3
to create, query, and update databases. We’ll also cover how to simplify working with SQLite databases using the pandas package. We’ll be using Python 3.5
, but this same approach should work with Python 2
.
SQLite是一个数据库引擎,可以简化关系数据的存储和使用。 与csv格式非常相似,SQLite将数据存储在单个文件中,可以轻松地与其他人共享。 大多数编程语言和环境都支持使用SQLite数据库。 Python也不例外,Python自2.5
版起就包含了一个用于访问SQLite数据库的库,称为sqlite3
。 在本文中,我们将逐步介绍如何使用sqlite3
创建,查询和更新数据库。 我们还将介绍如何使用pandas包简化使用SQLite数据库的工作。 我们将使用Python 3.5
,但是这种方法也可以在Python 2
。
翻译自: https://www.pybloggers.com/2016/10/working-with-sqlite-databases-using-python-and-pandas/