Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to open database error on first run of data_to_database.py #1

Open
wadbr opened this issue Feb 17, 2018 · 4 comments
Open

unable to open database error on first run of data_to_database.py #1

wadbr opened this issue Feb 17, 2018 · 4 comments
Labels

Comments

@wadbr
Copy link

wadbr commented Feb 17, 2018

Hey, I'm getting this error when I run the file, I cannot run any other of the py scripts, I manually installed lxml and peewee (with pip)

Running Win10x64, Python 3.6.4 (both 32 and 64 versions installed) , lxml==4.1.1, peewee==3.0.18, pytz==2018.3

I'm sure I'm doing something wrong and stupid, so sorry if that is the case

C:\Users\WSamsung\Desktop\MessengerDataOrganizer-master\python_implementation>python data_to_database.py
Traceback (most recent call last):
File "C:\Users\WSamsung\AppData\Local\Programs\Python\Python36-32\lib\site-packages\peewee.py", line 2434, in connect
self._state.set_connection(self._connect())
File "C:\Users\WSamsung\AppData\Local\Programs\Python\Python36-32\lib\site-packages\peewee.py", line 2654, in _connect
**self.connect_params)
sqlite3.OperationalError: unable to open database file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "data_to_database.py", line 7, in
import data_to_db_additional_modules.database_configuration as ds
File "C:\Users\WSamsung\Desktop\MessengerDataOrganizer-master\python_implementation\data_to_db_additional_modules\database_configuration.py", line 78, in
db.connect()
File "C:\Users\WSamsung\AppData\Local\Programs\Python\Python36-32\lib\site-packages\peewee.py", line 2435, in connect
self._initialize_connection(self._state.conn)
File "C:\Users\WSamsung\AppData\Local\Programs\Python\Python36-32\lib\site-packages\peewee.py", line 2287, in exit
reraise(new_type, new_type(*exc_args), traceback)
File "C:\Users\WSamsung\AppData\Local\Programs\Python\Python36-32\lib\site-packages\peewee.py", line 170, in reraise
raise value.with_traceback(tb)
File "C:\Users\WSamsung\AppData\Local\Programs\Python\Python36-32\lib\site-packages\peewee.py", line 2434, in connect
self._state.set_connection(self._connect())
File "C:\Users\WSamsung\AppData\Local\Programs\Python\Python36-32\lib\site-packages\peewee.py", line 2654, in _connect
**self.connect_params)
peewee.OperationalError: unable to open database file

@piotrek-k
Copy link
Owner

piotrek-k commented Feb 19, 2018

Hi,
This error usually appears when *.db file (the one where database is saved) is being used by other apps or you don't have permission to edit it. Try to run this script with administrator privileges.

Also one possible solution came to my mind: do you have a folder named doNotSync in appData folder? It should be created automatically but, being honest, that's the thing I haven't tested yet. Here I specified a path to possible database location and that's where my script tries to create database. Maybe it can't find this specific path and this is the reason why it throws error.

Try creating doNotSync folder (exactly here in folder tree of my code) and check if it works.

@piotrek-k piotrek-k added the bug label Feb 19, 2018
@wadbr
Copy link
Author

wadbr commented Feb 19, 2018

Okay so I uninstalled all my python versions, reinstalled the latest (3.6.5 x64) and moved the scripts to c:\ (I thought that maybe there would be a problem with either my multiple python versions or permissions to access data in the desktop). This seems to have fixed the original problem.

I also changed the db path as you showed me to the main folder
PATH_TO_DB = "C:\MessengerDataOrganizer-master\python_implementation\database.db"

Then running the script I got this error when running data_to_database.py,

C:\WINDOWS\system32>python C:\MessengerDataOrganizer-master\python_implementation\data_to_database.py
Traceback (most recent call last):
File "C:\MessengerDataOrganizer-master\python_implementation\data_to_database.py", line 7, in
import data_to_db_additional_modules.database_configuration as ds

File "C:\MessengerDataOrganizer-master\python_implementation\data_to_db_additional_modules\database_configuration.py", line 79, in
db.create_tables([User, Chat, Message], True)
TypeError: create_tables() takes 2 positional arguments but 3 were given

The db files actually gets created now, it is an empty file though,

@piotrek-k
Copy link
Owner

I uninstalled all my python versions, reinstalled the latest (3.6.5 x64) and moved the scripts to c:\

I also changed the db path as you showed me to the main folder

No, I definitely haven't told you to do any of that xD

I've reproduced steps you could have done trying to run my scripts and I've fixed possible issues (ad8c3a3). As you started to modify original code (which I don't recommend because I won't be able to help you after that), I recommend you to do the following:

  1. Delete my repo from your computer
  2. Clone it from github again (so it will contain my today's fixes)
  3. Try to run it

@wadbr
Copy link
Author

wadbr commented Feb 20, 2018

Redownloaded and still getting the same create_table error, the doNotSync folder gets created with an empty db file. The same error happens in all 3 of the scripts (line 1 in data_analysis.py and fix_meta_of_media_files.py, line 9 in the main script) and they all point to the same line in database_configuration.py.

C:\Messenger\MessengerDataOrganizer-master\python_implementation>python data_to_database.py
Traceback (most recent call last):
File "data_to_database.py", line 7, in
import data_to_db_additional_modules.database_configuration as ds
File "C:\Messenger\MessengerDataOrganizer-master\python_implementation\data_to_db_additional_modules\database_configuration.py", line 91, in
db.create_tables([User, Chat, Message], True)

Maybe this is because of a new/old version of a module or python? Theoretically the script can create and modify the db file, its permissions and modification rights are all okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants