数据库-python SQLite3

数据库-python SQLite3

  • 一:sqlite3 简介
  • 二: sqlite3 流程
    • 1> demo
    • 2> sqlite3 流程
  • 三:sqlite3 step
    • 1> create table
    • 2> insert into
    • 3> update
    • 4> select
      • 1. fetchall()
      • 2. fetchone()
      • 3. fetchmany()
    • 5> delete
    • 6> other step
  • 四: Mysql
    • 1> Mysql知识详解

一:sqlite3 简介

sqlite3 是一个内置的Python模块,可以通过Python的标准库轻松地使用,无需进行额外安装和配置。sqlite3 支持SQL语句,对数据库的操作简单高效。因此,sqlite3 非常适用于小型项目和单机应用程序,是Python开发中常用的数据库解决方案之一,能为程序提供完整的数据库解决方案.

二: sqlite3 流程

1> demo

utils_sqlite3.py

import sqlite3
import logging
logger = logging.getLogger("utils_sqlite3")

def excute_sql(sql_connect, sql_cmd):
    sql_cursor = sql_connect.cursor()
    # logging.info(sql_cmd)
    try:
        sql_cursor.execute(sql_cmd)
        sql_connect.commit()
        sql_cursor.close()
    except Exception as e:
        logger.error(f"sqlite3.OperationalError: {e}")
        raise

你可能感兴趣的:(数据库,python,数据库)