Thanks for the reply,
ls -lah /media/routerhd/DataMeteo/
returns the list of files contained in the directory.
The folder is accessible as well as the disk where I have other applications that save the files
osmc@osmc:~/www/Meteo$ ls -lah /media/routerhd/DatiMeteo/
total 0
drwxr-xr-x 2 osmc osmc 0 Jul 3 14:47 .
drwxr-xr-x 2 osmc osmc 0 Jul 2 23:04 ..
-rwxr-xr-x 1 osmc osmc 0 Jul 3 12:16 datimet.sqlite
-rwxr-xr-x 1 osmc osmc 0 Jul 3 11:03 datimet3.sqlite
-rwxr-xr-x 1 osmc osmc 0 Jul 3 14:36 datimet4.sqlite
-rwxr-xr-x 1 osmc osmc 0 Jul 3 14:47 datimet4.sqlite22
drwxr-xr-x 2 osmc osmc 0 Jul 3 10:28 old
osmc@osmc:~/www/Meteo$
the disk is mounted with /etc/fstab
//192.168.1.1/fritznas/Elements /media/routerhd cifs noauto,noserverino,x-systemd.automount,username=xxxxx,password=yyyyy,uid=osmc,gid=osmc,iocharset=utf8,noperm,rw 0 0
the python function that creates a sqlite database file on the path /media/routerhd/DataMeteo/ is this:
import sqlite3
import os
import shutil
def create_database(database_path):
# Verifica se il database esiste gia
if os.path.exists(database_path):
print("Il database esiste.")
return
# Messaggio di saluto
print("Welcome!")
try:
# Crea una connessione al database
conn = sqlite3.connect(database_path)
# Crea un oggetto "cursor" per eseguire le query
cursor = conn.cursor()
# Crea la tabella "meteo" con i campi desiderati
create_table_query = """
CREATE TABLE meteo (
DateTime TEXT,
OutTemp TEXT,
OutUmid TEXT,
InTemp TEXT,
InUmid TEXT,
DevPoint TEXT,
WindTemp TEXT,
WindSpeed TEXT,
WindGust TEXT,
WindDir TEXT,
RainDif TEXT,
RainTot TEXT,
Pressure TEXT
)
"""
cursor.execute(create_table_query)
# Chiudi il cursore
cursor.close()
# Chiudi la connessione al database
conn.close()
print("Database creato con successo.")
except sqlite3.Error as e:
print("Si e verificato un errore:", e)
This file is called db.py
and i call the function from another file like this sudo python weather.py
on other locations it works but on the path of the network hard disk /media/routerhd/DataMeteo
/ it generates an error and a sqlite corrupted file.