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

[ERROR] OperationalError: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) #6561

Closed
hafsa-eja opened this issue Jan 16, 2024 · 5 comments
Labels
area/remote/invoke sam remote invoke command blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale.

Comments

@hafsa-eja
Copy link

hafsa-eja commented Jan 16, 2024

I am using python version 3.9 and on windows 10 I am trying to make a chatterbot using flask and present it on aws it deployed and build correctly but when I tried to invoke it gives the following issue:

(myenv) C:\Users\HafsaEjaz\Pictures\proj\myenv\sam-app>sam remote invoke HelloWorldFunction --stack-name sam-app
Invoking Lambda Function HelloWorldFunction
[ERROR] OperationalError: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8)
Traceback (most recent call last):
  File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/var/task/app.py", line 2, in <module>
    from chatbot import chatbot
  File "/var/task/chatbot.py", line 6, in <module>
    chatbot = ChatBot(
  File "/var/task/chatterbot/chatterbot.py", line 35, in __init__
    self.storage = utils.initialize_class(storage_adapter, **kwargs)
  File "/var/task/chatterbot/utils.py", line 54, in initialize_class
    return Class(*args, **kwargs)
  File "/var/task/chatterbot/storage/sql_storage.py", line 46, in __init__
    if not self.engine.dialect.has_table(self.engine, 'Statement'):
  File "/var/task/sqlalchemy/dialects/sqlite/base.py", line 1356, in has_table
    info = self._get_table_pragma(
  File "/var/task/sqlalchemy/dialects/sqlite/base.py", line 1799, in _get_table_pragma
    cursor = connection.execute(statement)
  File "/var/task/sqlalchemy/engine/base.py", line 2143, in execute
    connection = self.contextual_connect(close_with_result=True)
  File "/var/task/sqlalchemy/engine/base.py", line 2192, in contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/var/task/sqlalchemy/engine/base.py", line 2231, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/var/task/sqlalchemy/engine/base.py", line 1528, in _handle_dbapi_exception_noconnection
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/var/task/sqlalchemy/util/compat.py", line 296, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/var/task/sqlalchemy/util/compat.py", line 276, in reraise
    raise value.with_traceback(tb)
  File "/var/task/sqlalchemy/engine/base.py", line 2228, in _wrap_pool_connect
    return fn()
  File "/var/task/sqlalchemy/pool.py", line 434, in connect
    return _ConnectionFairy._checkout(self)
  File "/var/task/sqlalchemy/pool.py", line 831, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/var/task/sqlalchemy/pool.py", line 563, in checkout
    rec = pool._do_get()
  File "/var/task/sqlalchemy/pool.py", line 1355, in _do_get
    return self._create_connection()
  File "/var/task/sqlalchemy/pool.py", line 379, in _create_connection
    return _ConnectionRecord(self)
  File "/var/task/sqlalchemy/pool.py", line 508, in __init__
    self.__connect(first_connect_check=True)
  File "/var/task/sqlalchemy/pool.py", line 710, in __connect
    connection = pool._invoke_creator(self)
  File "/var/task/sqlalchemy/engine/strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
  File "/var/task/sqlalchemy/engine/default.py", line 437, in connect
    return self.dbapi.connect(*cargs, **cparams)INIT_REPORT Init Duration: 1878.47 ms   Phase: init     Status: error   Error Type: Runtime.ExitError
INIT_REPORT Init Duration: 3053.87 ms   Phase: invoke   Status: error   Error Type: Runtime.Unknown
START RequestId: 803b5026-972d-42ed-b35a-111dac134758 Version: $LATEST
2024-01-16T11:45:41.521Z 803b5026-972d-42ed-b35a-111dac134758 Task timed out after 3.08 seconds

END RequestId: 803b5026-972d-42ed-b35a-111dac134758
REPORT RequestId: 803b5026-972d-42ed-b35a-111dac134758  Duration: 3076.02 ms    Billed Duration: 3000 ms        Memory Size: 128 MB     Max Memory Used: 18 MB
{"errorMessage":"2024-01-16T11:45:41.521Z 803b5026-972d-42ed-b35a-111dac134758 Task timed out after 3.08 seconds"}

while my code of chattbot app.py is:

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer

# Creating ChatBot Instance
chatbot = ChatBot(
    'Terminal',
    #storage_adapter='chatterbot.storage.SQLStorageAdapter',
    logic_adapters=[
        
       # 'chatterbot.logic.BestMatch',
        {
            'import_path': 'chatterbot.logic.BestMatch',
            'default_response': 'I am sorry, but I do not understand. Can you rephrase your query?',
            'maximum_similarity_threshold': 0.95
        }
    ],

)

 # Training with Personal Ques & Ans 
training_data_simple = open('training_data/ques_ans.txt').read().splitlines()
training_data_personal = open('training_data/personal_ques.txt').read().splitlines()
#print("Loaded training data")
training_data = training_data_simple + training_data_personal

trainer = ListTrainer(chatbot)
trainer.train(training_data)

# Training with English Corpus Data 
trainer_corpus = ChatterBotCorpusTrainer(chatbot)
#print("Done loading")
@hafsa-eja hafsa-eja added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jan 16, 2024
@hafsa-eja hafsa-eja changed the title sqlite3.OperationalError [ERROR] OperationalError: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8) Jan 16, 2024
@hnnasit
Copy link
Contributor

hnnasit commented Jan 17, 2024

Hi @hafsa-eja, it seems the traceback error is thrown by the lambda script and not sam remote invoke command. sam remote invoke is displaying the output after running the lambda script. Can you check if the lambda function works on AWS console and if the python script runs as expected? I also noticed the errorMessage mentions the lambda timed out after 3 seconds, can you try increasing the lambda timeout?

@hnnasit hnnasit added blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. area/remote/invoke sam remote invoke command and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jan 17, 2024
@hafsa-eja
Copy link
Author

Hi @hnnasit I tried running python code it worked correctly I increased the timeout parameter, but the error is still the same unable to open database file ... and tried running lambda function to see if it works on AWS console but it gives the exact same error there too.

@hnnasit
Copy link
Contributor

hnnasit commented Apr 18, 2024

Is the database file you are trying to open present in the lambda code? The error seems to be coming from the python dependencies from Lambda. My hunch tells me this might not be a SAM CLI issue.

@hnnasit
Copy link
Contributor

hnnasit commented Sep 10, 2024

Closing this issue as it's been stale for a while. Please open a new issue if you still have questions or concerns. The issue doesn't seem to be from sam remote invoke.

@hnnasit hnnasit closed this as completed Sep 10, 2024
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/remote/invoke sam remote invoke command blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale.
Projects
None yet
Development

No branches or pull requests

2 participants