SQLite inoperable in Python program executable created by cx_Freeze

0

I made a simple application in Python 3.6 and SQLite3.

When I generate the main program executable by cx_Freeze and install it on the machine I developed the application (where Python and SQLite are installed), the application works fine, including, deleting, querying and changing the data in the databases.

The problem is when I install this application on another computer that does not have Python and SQLite installed. When there is an interaction with the databases, it does not return any error and simply the program does not respond, as if it were not accessing the databases.

What do I still need to put in the setup.py file so that the application can effectively access SQLite databases? Do I have to put any more command on the programs that access the bases? To help, I refer below the program setup.py and a program that accesses SQLite.

Setup.py program:

#setup.py
import os
import sys
os.environ['TCL_LIBRARY'] = "C:\Users\Paulo\AppData\Local\Programs\Python\Python36\tcl\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\Users\Paulo\AppData\Local\Programs\Python\Python36\tcl\tk8.6"
from cx_Freeze import setup, Executable
setup(
name = "Sistema RMI",
version = "1.0.2",
options = {"build_exe": {
    'packages': ["os","sys","ctypes","time","sqlite3","datetime"],
    'include_files':[r"C:\Users\Paulo\AppData\Local\Programs\Python\Python36\DLLs\tcl86t.dll", 
                     r"C:\Users\Paulo\AppData\Local\Programs\Python\Python36\DLLs\tk86t.dll", 
                     r"C:\Users\Paulo\AppData\Local\Programs\Python\Python36\DLLs\sqlite3.dll"],
    'include_msvcr': True,
}},
executables = [Executable("PgmPrin.py",base="win32GUI")]
)

Database Access Program:

import sqlite3

class BancoInpcDB():

    def __init__(self):
        self.conexao = sqlite3.connect('bancoInpcDB.db')
        self.createTable()

    def createTable(self):
        c = self.conexao.cursor()

        c.execute("""create table if not exists inpc (
                    anomes integer primary key ,
                    percentual numeric(2,4) not null,
                    validacao char(1) not null)""")

        self.conexao.commit()
        c.close()
    
asked by anonymous 28.04.2017 / 01:55

1 answer

0

I discovered what was happening. I tried to make an insert into one of the SQLite files of my system, through the SQLlite Manager of Firefox, and received the following message: "NS_ERROR_FILE_READ_ONLY", that is, I was missing authorization as a directory administrator in order to access the application. So I ran my application as an administrator and the system started working correctly. That way, there were no problems with SQLite and what I lacked was a bit more experience in developing with Python to tell the error message the real problem that was occurring with accessing the database.

    
05.05.2017 / 13:49