Sqlite unable to open database file python

Sqlite unable to open database file python

Hey. When I try to run syncdb, it gives me this error:

sqlite3.OperationalError: unable to open database file

I’ve read some things on the internet that say the path is probably wrong, but it isn’t.

Traceback (most recent call last): File «manage.py», line 10, in execute_from_command_line(sys.argv) File «/Library/Python/2.7/site-packages/django/core/management/__init__.py», line 443, in execute_from_command_line utility.execute() File «/Library/Python/2.7/site-packages/django/core/management/__init__.py», line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File «/Library/Python/2.7/site-packages/django/core/management/base.py», line 196, in run_from_argv self.execute(*args, **options.__dict__) File «/Library/Python/2.7/site-packages/django/core/management/base.py», line 232, in execute output = self.handle(*args, **options) File «/Library/Python/2.7/site-packages/django/core/management/base.py», line 371, in handle return self.handle_noargs(**options) File «/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py», line 57, in handle_noargs cursor = connection.cursor() File «/Library/Python/2.7/site-packages/django/db/backends/__init__.py», line 306, in cursor cursor = self.make_debug_cursor(self._cursor()) File «/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py», line 281, in _cursor self._sqlite_create_connection() File «/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py», line 271, in _sqlite_create_connection self.connection = Database.connect(**kwargs) sqlite3.OperationalError: unable to open database file

Please help! I’ve tried everything!

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

Читайте также:  Python shutil move directory

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

sqlite3.OperationalError: unable to open database file #1248

sqlite3.OperationalError: unable to open database file #1248

Comments

hi,
I installed the telethon correctly and according to the documentation I tried to login But every time I encounter the following error

sqlite3.OperationalError: unable to open database file

There is also a filter telegram in my country and I use mtpproxy to work with the library
Can anyone help? plz

The text was updated successfully, but these errors were encountered:

I also checked the permissions for the script file, There was full permission to write, read and execute, I also checked this for the directory where the library is located. All files and folders had full access.
I also run the script of the program with the administrator rights.
So where can the problem be?

Well, the latest version works correctly for me, so there must be something wrong in your environment. Not a bug in the library.

2019-08-13 11:47:14,166 (util.py:65 WorkerThread12) ERROR - TeleBot: "OperationalError occurred, args=('unable to open database file',) Traceback (most recent call last): File "venv/lib/python3.7/site-packages/telebot/util.py", line 59, in run task(*args, **kwargs) File "venv/lib/python3.7/site-packages/telethon/client/telegrambaseclient.py", line 214, in __init__ session = SQLiteSession(session) File "venv/lib/python3.7/site-packages/telethon/sessions/sqlite.py", line 46, in __init__ c = self._cursor() File "venv/lib/python3.7/site-packages/telethon/sessions/sqlite.py", line 218, in _cursor check_same_thread=False) sqlite3.OperationalError: unable to open database file 

@markolofsen posting in three different issues won’t help. Pick or open a new one, and you will get the same response I gave in #944 (comment).

FYI this can happen if you deleted the sessions directory accidentally. Just create it again & it should work.

Hello, I had the same problem and even playing with the permissions did not solve the problem.

In fact, I realized that it was due to the fact that I was not building my telegram client at the same level.

Let’s say you have the following architecture (both files at same level):

Everything will work as expected, since we call the file that builds the telegram client at the same level as the session file

But in my case, I added a main.py file that calls the my_telegram_client file to create my telegram client and then I get the error mentioned above.

main.py
src/my_telegram_client.py
src/my_session.session

To solve this error, just specify the absolute path of the session file when creating the telegram client.

Exemple : TelegramClient(‘/Users/john/MyProject/src/my_session.session’, app_id, app_bash)

Hi, I have the same issue when running my program on ubuntu.
It works fine in windows, but the same code is giving:
File «/home/test/get.py», line 14, in
get_bot_session()
File «/home/test/get.py», line 5, in get_bot_session
client = TelegramClient(BOT_TOKEN, API_ID, API_HASH)
File «/home/ubuntu/.local/lib/python3.11/site-packages/telethon/client/telegrambaseclient.py», line 289, in init
session = SQLiteSession(session)
File «/home/ubuntu/.local/lib/python3.11/site-packages/telethon/sessions/sqlite.py», line 47, in init
c = self._cursor()
File «/home/ubuntu/.local/lib/python3.11/site-packages/telethon/sessions/sqlite.py», line 242, in _cursor
self._conn = sqlite3.connect(self.filename,
sqlite3.OperationalError: unable to open database file
error on ubuntu
Any ideas?
P.S. I run it as administrator, all files have permissions.

BOT_TOKEN likely has : in its path, which likely is not a valid session path.

I checked for «:» too and it wasn’t the issue.
I solved the issue by just using older version of the python.
My server was running python 3.11.3 which kept giving this error, then I tried using python 3.8 to run the application which worked for me.
Anyways thanks for quick reply.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

sqlite3.OperationalError: unable to open database file #1248

sqlite3.OperationalError: unable to open database file #1248

Comments

hi,
I installed the telethon correctly and according to the documentation I tried to login But every time I encounter the following error

sqlite3.OperationalError: unable to open database file

There is also a filter telegram in my country and I use mtpproxy to work with the library
Can anyone help? plz

The text was updated successfully, but these errors were encountered:

I also checked the permissions for the script file, There was full permission to write, read and execute, I also checked this for the directory where the library is located. All files and folders had full access.
I also run the script of the program with the administrator rights.
So where can the problem be?

Well, the latest version works correctly for me, so there must be something wrong in your environment. Not a bug in the library.

2019-08-13 11:47:14,166 (util.py:65 WorkerThread12) ERROR - TeleBot: "OperationalError occurred, args=('unable to open database file',) Traceback (most recent call last): File "venv/lib/python3.7/site-packages/telebot/util.py", line 59, in run task(*args, **kwargs) File "venv/lib/python3.7/site-packages/telethon/client/telegrambaseclient.py", line 214, in __init__ session = SQLiteSession(session) File "venv/lib/python3.7/site-packages/telethon/sessions/sqlite.py", line 46, in __init__ c = self._cursor() File "venv/lib/python3.7/site-packages/telethon/sessions/sqlite.py", line 218, in _cursor check_same_thread=False) sqlite3.OperationalError: unable to open database file 

@markolofsen posting in three different issues won’t help. Pick or open a new one, and you will get the same response I gave in #944 (comment).

FYI this can happen if you deleted the sessions directory accidentally. Just create it again & it should work.

Hello, I had the same problem and even playing with the permissions did not solve the problem.

In fact, I realized that it was due to the fact that I was not building my telegram client at the same level.

Let’s say you have the following architecture (both files at same level):

Everything will work as expected, since we call the file that builds the telegram client at the same level as the session file

But in my case, I added a main.py file that calls the my_telegram_client file to create my telegram client and then I get the error mentioned above.

main.py
src/my_telegram_client.py
src/my_session.session

To solve this error, just specify the absolute path of the session file when creating the telegram client.

Exemple : TelegramClient(‘/Users/john/MyProject/src/my_session.session’, app_id, app_bash)

Hi, I have the same issue when running my program on ubuntu.
It works fine in windows, but the same code is giving:
File «/home/test/get.py», line 14, in
get_bot_session()
File «/home/test/get.py», line 5, in get_bot_session
client = TelegramClient(BOT_TOKEN, API_ID, API_HASH)
File «/home/ubuntu/.local/lib/python3.11/site-packages/telethon/client/telegrambaseclient.py», line 289, in init
session = SQLiteSession(session)
File «/home/ubuntu/.local/lib/python3.11/site-packages/telethon/sessions/sqlite.py», line 47, in init
c = self._cursor()
File «/home/ubuntu/.local/lib/python3.11/site-packages/telethon/sessions/sqlite.py», line 242, in _cursor
self._conn = sqlite3.connect(self.filename,
sqlite3.OperationalError: unable to open database file
error on ubuntu
Any ideas?
P.S. I run it as administrator, all files have permissions.

BOT_TOKEN likely has : in its path, which likely is not a valid session path.

I checked for «:» too and it wasn’t the issue.
I solved the issue by just using older version of the python.
My server was running python 3.11.3 which kept giving this error, then I tried using python 3.8 to run the application which worked for me.
Anyways thanks for quick reply.

Источник

Оцените статью