简体   繁体   中英

Jenkins Job - DatabaseError: file is encrypted or is not a database

When running this code for connecting to a db through cmd - locally and on the actual server it works fine. But I have set it up on Jenkins and receive the error:

DatabaseError: file is encrypted or is not a database

It seems to be happening on this line:

  self.cursor.execute(*args)

The database class is:

class DatabaseManager(object):
    def __init__(self, db):
        self.conn = sqlite3.connect(db)
        self.cursor = self.conn.cursor()

    def query(self, *args):
        self.cursor.execute(*args)
        self.conn.commit()
        return self.cursor

    def __del__(self):
        self.conn.close()

The version of python sqlite3 and Command Line sqlite3 can be different. Create your database from the script ie code the DB initialization in the script rather than from CMD and it might solve the problem.

What is the value of *args ?? is it having the same values that you have when you run it on cmd and through jenkins, Did you check the path and location of DB related from jenkins location??

It's most probably a version mismatch between the SQLite CLI you're using and the one bundled with Python. You can have such mismatch on the same server, too. To be sure, you can use Python instead of the SQLite CLI to create your DB on the sever - provided you have all your SQLite init structure in path/to/your_sql.sql you can initialize path/to/your_database.db database with a script like:

import sqlite3

connection = sqlite3.connect("path/to/your_database.db")
cursor = connection.cursor()
with open("path/to/your_sql.sql", "r") as f:
    cursor.execute(f.read())
connection.commit()

Then try to load that DB from your Jenkins job.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM