Python代码库之将图片文件存在到sqlite数据库中
2023-09-11 14:18:32 时间
# encoding: utf-8
import sqlite3
from PIL import Image
import os
'''
from file2db import *
dbname='kx.db'
pathbase='image'
paraList=os.listdir(pathbase)
mdx2db(dbname,paraList,pathbase)
'''
def mdx2db(dbname,paraList,pathbase):
if os.path.isfile(dbname):
os.remove(dbname)
createdb(dbname)
#sqlite
import sqlite3
conn = sqlite3.connect(dbname)
c = conn.cursor()
for item in paraList:
#msql='''INSERT INTO mword (tupian,geshi ) VALUES (?,?)'''
msql='''INSERT INTO mword (tupian,geshi,image ) VALUES (?,?,?)'''
filename, file_extension = os.path.splitext(item)
imgPath=pathbase+'/'+item
with open(imgPath, 'rb') as input_file:image = input_file.read()
para=(filename,file_extension,im
相关文章
- 【Python成长之路】python并发学习:多进程与多线程的用法及场景介绍
- Python 文件I/O
- Python操作SQLite数据库的方法详解
- python 模块
- Python 进阶(四)类的继承
- python: easyocr的安装和使用(easyocr 1.6.2 / Python 3.7.15 )
- Atitit web httphandler的实现 java python node.js c# net php 目录 1.1. Java 过滤器 servelet1 1.2. Python的
- android.database.sqlite.SQLiteException: no such table: xxx (code 1 SQLITE_ERROR): , while compiling
- GitHub 热门:各大网站的 Python 爬虫登录汇总
- Python编程:利用python编程实现对基于时间序列的数据(dataframe格式)按照指定时间范围进行单方向关联,不存在的日期补充为默认的NaN
- Python之多线程:python多线程设计之同时执行多个函数命令详细攻略
- Python语言学习之文件夹那些事:python和文件夹的使用方法之详细攻略
- Python:python语言中与时间有关的库函数简介、安装、使用方法(获取当前时间/计算程序块前后运行时间/模型训练时间或耗费时间)之详细攻略
- Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(Canvas)
- Python之多线程:python多线程设计之同时执行多个函数命令详细攻略
- Python的IDE:基于Eclipse/MyEclipse软件的PyDev插件配置python的开发环境(不同python项目加载不同版本的python)—从而实现Python编程图文教程之详细攻略
- 已解决2.Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and wi
- 〖Python自动化办公篇⑲〗 - python实现邮件自动化 - 邮件发送
- Python 的 sum():Pythonic 的求和方法
- 【Python成长之路】python并发学习:多进程与多线程的用法及场景介绍
- python 根据输入的内容输出类型
- 【华为OD机试Python实现】HJ25 数据分类处理(较难)
- Python编程:shelve模块-持久化python数据
- Python编程:PyCharm对Python虚拟环境和第三方包管理实践
- python IDLE 背景修改 IDLE (Python GUI)
- python基础===Python 迭代器模块 itertools 简介
- python基础===八大排序算法的 Python 实现
- 【Leetcode刷题Python】高效求递归中函数的调用次数(动态规划方法,顺丰笔试题)
- 〖Python自动化办公篇⑳〗 - python实现邮件自动化 - 发送html邮件和带附件的邮件
- Python基于OpenCV的实时疲劳检测[源码&演示视频&部署教程]
- yolov4视频目标检测:使用C++版本联合CUDA11.2的OpenCV 5.x编译生成opencv-python==5.x进行推理