sqlalchemy.exc.ObjectNotExecutableError: Not an executable object: 'select 1'
问题
在flask框架中连接数据库,并测试数据库是否连接成功
使用了mysql数据库和pymysql驱动
问题描述
代码
db = SQLAlchemy(app) with app.app_context(): with db.engine.connect() as conn: rs = conn.execute('select 1') print(rs.fetchone()) # (1,)
抛出问 …
Conda操作命令
-
conda remove -n your_env_name --all
-
conda create -n your_env_name pytohn==3.6
-
conda deactivate
-
source activate your_env_name
-
conda info –-e
-
conda config --set auto_activate_base false
-
编辑 ~.bashrc
只要在此文件末尾加一行就搞定
conda activate your_envs # "your_envs"就是你的 …
python-批量重命名文件
工作需要批量修改图片文件名,但是保留文件的前几位名字,写了个简单的python 脚本,内容如下:
#-*-coding:GBK -*- # ---------------by Terry.Gu 2021.6.30 import os import time …more ...
当前文件夹下PDF文件页码计数
import PyPDF2 import time import os file_name = os.listdir(os.getcwd()) # 获取当前路径 file_typ = ".pdf" pdf_list = [] b = 0 totalpag = 0 for n in file_name: if file_typ in n: #判断是否是PDF文件 print("Found PDF file:" + n) pdf_list.append(n) pdfReader = PyPDF2.PdfFileReader(n …more ...
PDF中提取图片
- 安装库
C:\Users\*****>pip install pymupdf Collecting pymupdf Downloading PyMuPDF-1.17.5-cp38-cp38-win_amd64.whl (5.1 MB) |████████████████████████████████| 5.1 MB 273 kB/s Installing collected packages: pymupdf Successfully installed pymupdf-1.17.5 C:\Users\*****>
- python 脚本
import fitz import time import re import os def pdf2pic(path, pic_path …more ...
Python 复制文件到新的路径
import shutil
path = 'd:\11111\test.py'
newpath = 'd:\2222\test.py'
shutil.copy(path, newpath)more ...
python 列出文件夹下所有的文件以及文件夹名
import os path = 'D:\******……' #定义路径 folders = os.listdir(path) for folder in folders: print(folder)more ...
python3 print格式化输出---------"%s 和 % d"
打印字符串
>>> string="hello" >>> print("string=%s"%(string)) 输出: string=hello
2.打印整数
>>> print ("He is %d years old"%(25)) 输出: He is 25 years old
3.打印浮点数
>>>print ("His height is %f m"%(1.83)) 输出 …more ...