使用SQLite数据库从.py构建.exe文件 [英] Build a .exe file from .py with SQLite database

查看:111
本文介绍了使用SQLite数据库从.py构建.exe文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

程序进行约会,并将约会安排在时间表中,并写入QsQLite数据库。该程序从.py运行,但是我需要它在.exe中。
我已经使用cx_Freeze创建一个.exe文件,但是该程序不会生成SQLite数据库。
这是我的安装文件:

Program makes appointments and places them into schedule which are written in QsQLite database. The program runs from .py but I need it to be in .exe. I have used cx_Freeze to create an .exe file, but the program does not generate the SQLite database. So here is my setup file:

from cx_Freeze import setup, Executable
import os
import sys

os.environ['TCL_LIBRARY'] = r'C:\Program Files\Python35\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files\Python35\tcl\tk8.6'


build_exe_options = {"packages": [
  'os','sys','sqlite3'], 'include_files': [os.path.join(sys.base_prefix, 'DLLs', 'sqlite3.dll'), 'main.py','util.py','data.db']}

setup(
    name = "Eclients",
    version = "0.1",
    options = {"build_exe": build_exe_options},
    executables = [Executable("main.py")]
)

数据库无法打开

那么,如何解决呢?

推荐答案

通过从 C:\Program Files\Python35\Lib\site-packages\PyQt5\plugins 进入main.exe目录。

Solved this problem by copying the whole 'sqldrivers' folder from C:\Program Files\Python35\Lib\site-packages\PyQt5\pluginsto main.exe directory.

这篇关于使用SQLite数据库从.py构建.exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆