Python Forum
Sqlite permissions problem. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Sqlite permissions problem. (/thread-3661.html)



Sqlite permissions problem. - feat7 - Jun-11-2017

Hello there!
I just started writing in python. I am facing some issue regarding permissions to SQLite.
This is my repo github.com/feat7/medium-scrapper
After installation, as the data.db goes to /usr/local/lib/.... (in Ubuntu 16.04) I get some problem in writing to the database. If I simply use
sudo medium it will not work because I am using selenium (chromedriver) so it won't open as root. I made it work somehow by chmod 777 -R to that path, but I'll need to repeat every time I install it with setup.py. Please help me if I can do another way round.


RE: Sqlite permissions problem. - wavic - Jun-11-2017

If you just need to read/write to the database file just change its permissions. And the owner too
Fist, try with the owner

sudo chown user_name:user_name /path/database_file_name
And then try the program. If doesn't work change the permissions

sudo chmod 660 /path/database_file_name



RE: Sqlite permissions problem. - feat7 - Jun-12-2017

(Jun-11-2017, 05:31 PM)wavic Wrote: If you just need to read/write to the database file just change its permissions. And the owner too
Fist, try with the owner

sudo chown user_name:user_name /path/database_file_name
And then try the program. If doesn't work change the permissions

sudo chmod 660 /path/database_file_name

As described already, I have done this. My problem is whenever I setup I need to repeat the procedure. I need some better approach, that's what I am looking.


RE: Sqlite permissions problem. - wavic - Jun-12-2017

The script is looking into the same directory where it is located. According to this:

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
db_path = os.path.join(BASE_DIR, "data.db")

db = sqlite3.connect(db_path)
I don't know what the installation does, but try to put the database file along with the scirpt