Я настраиваю приложение, используя nginx + flask + sqlite и работаю с файлами и каталогами (загрузка / загрузка)
Ниже приведен код подключения БД:
try:
connection = sqlite3.connect('database.sqlite')
cursor = connection.cursor()
if action == "all":
cursor.execute("SELECT * FROM files")
records = cursor.fetchall()
connection.commit()
return records
elif action == "select":
cursor.execute("SELECT * FROM files WHERE id=(?)",(value,))
result = json.dumps(cursor.fetchall())
connection.commit()
return result
elif action == "insert":
records = json.loads(value)
cursor.execute('INSERT INTO files (name, hash, type, timestamp, attempts) VALUES ("{}", "{}", "{}", "{}", "{}")'.format(records['name'], records['hash'], records['type'], records['timestamp'], "0"))
connection.commit()
elif action == "delete":
cursor.execute("DELETE FROM files WHERE id=(?)",(value,))
connection.commit()
else:
print("ERROR: UNKNOWN DATABASE ACTION!")
except sqlite3.Error as error:
print("Failed connecting to database...", error)
return 'error'
finally:
if (connection):
connection.close()
Iполучаю unable to open database file
, я проверил права доступа к файлам, сервер в целом выглядит нормально.
Спасибо