sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: file #24

Closed
opened 2020-06-10 20:14:25 +02:00 by samedamci · 3 comments
samedamci commented 2020-06-10 20:14:25 +02:00 (Migrated from github.com)
$ python fhost.py runserver


 * Serving Flask app "fhost" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
[2020-06-10 20:12:24,818] ERROR in app: Exception on / [POST]
Traceback (most recent call last):
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1283, in _execute_context
    self.dialect.do_execute(
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: file

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/samedamci/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "fhost.py", line 324, in fhost
    return store_file(request.files["file"], request.remote_addr)
  File "fhost.py", line 169, in store_file
    existing = File.query.filter_by(sha256=digest).first()
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3375, in first
    ret = list(self[0:1])
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3149, in __getitem__
    return list(res)
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3481, in __iter__
    return self._execute_and_instances(context)
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3506, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1020, in execute
    return meth(self, multiparams, params)
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1133, in _execute_clauseelement
    ret = self._execute_context(
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1323, in _execute_context
    self._handle_dbapi_exception(
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1517, in _handle_dbapi_exception
    util.raise_(
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
    raise exception
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1283, in _execute_context
    self.dialect.do_execute(
  File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: file
[SQL: SELECT file.id AS file_id, file.sha256 AS file_sha256, file.ext AS file_ext, file.mime AS file_mime, file.addr AS file_addr, file.removed AS file_removed, file.nsfw_score AS file_nsfw_score
FROM file
WHERE file.sha256 = ?
 LIMIT ? OFFSET ?]
[parameters: ('5f02bf8deae12565252f0d86c9c13608688ee262e1418c09034a5ad52b76c479', 1, 0)]
(Background on this error at: http://sqlalche.me/e/e3q8)
127.0.0.1 - - [10/Jun/2020 20:12:24] "POST / HTTP/1.1" 500 -

I have this error after run curl -F'file=@test.txt' http://127.0.0.1:5000 and also in client terminal I see

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or
there is an error in the application.</p>
``` $ python fhost.py runserver * Serving Flask app "fhost" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) [2020-06-10 20:12:24,818] ERROR in app: Exception on / [POST] Traceback (most recent call last): File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1283, in _execute_context self.dialect.do_execute( File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute cursor.execute(statement, parameters) sqlite3.OperationalError: no such table: file The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/samedamci/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/home/samedamci/.local/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "fhost.py", line 324, in fhost return store_file(request.files["file"], request.remote_addr) File "fhost.py", line 169, in store_file existing = File.query.filter_by(sha256=digest).first() File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3375, in first ret = list(self[0:1]) File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3149, in __getitem__ return list(res) File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3481, in __iter__ return self._execute_and_instances(context) File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3506, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1020, in execute return meth(self, multiparams, params) File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1133, in _execute_clauseelement ret = self._execute_context( File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1323, in _execute_context self._handle_dbapi_exception( File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1517, in _handle_dbapi_exception util.raise_( File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1283, in _execute_context self.dialect.do_execute( File "/home/samedamci/.local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: file [SQL: SELECT file.id AS file_id, file.sha256 AS file_sha256, file.ext AS file_ext, file.mime AS file_mime, file.addr AS file_addr, file.removed AS file_removed, file.nsfw_score AS file_nsfw_score FROM file WHERE file.sha256 = ? LIMIT ? OFFSET ?] [parameters: ('5f02bf8deae12565252f0d86c9c13608688ee262e1418c09034a5ad52b76c479', 1, 0)] (Background on this error at: http://sqlalche.me/e/e3q8) 127.0.0.1 - - [10/Jun/2020 20:12:24] "POST / HTTP/1.1" 500 - ``` I have this error after run `curl -F'file=@test.txt' http://127.0.0.1:5000` and also in client terminal I see ``` <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>500 Internal Server Error</title> <h1>Internal Server Error</h1> <p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p> ```

Did you create the database schema first, by running ./fhost.py db upgrade?

Did you create the database schema first, by running `./fhost.py db upgrade`?
samedamci commented 2020-06-11 13:20:10 +02:00 (Migrated from github.com)

Ok, sorry, I forgot for it, it works now... partially. I noticed next interesting problem. When I start dev server or uWSGI on port 5000 files aren't available in browser (blank page, no error). Only if I run debug server on port 4562 I can see published files and download it. My uWSGI command:

uwsgi --socket 0.0.0.0:4562 --protocol=http --wsgi-file fhost.py --callable app
Ok, sorry, I forgot for it, it works now... partially. I noticed next interesting problem. When I start dev server or uWSGI on port 5000 files aren't available in browser (blank page, no error). Only if I run debug server on port 4562 I can see published files and download it. My uWSGI command: ```shell uwsgi --socket 0.0.0.0:4562 --protocol=http --wsgi-file fhost.py --callable app ```
TheHamkerCat commented 2020-11-15 10:57:34 +01:00 (Migrated from github.com)

Ok, sorry, I forgot for it, it works now... partially. I noticed next interesting problem. When I start dev server or uWSGI on port 5000 files aren't available in browser (blank page, no error). Only if I run debug server on port 4562 I can see published files and download it. My uWSGI command:

uwsgi --socket 0.0.0.0:4562 --protocol=http --wsgi-file fhost.py --callable app

it is happening with me too after uploading a file via terminal when i check the link in a browser , all i get is a blank page.....You got any solution so far?

> Ok, sorry, I forgot for it, it works now... partially. I noticed next interesting problem. When I start dev server or uWSGI on port 5000 files aren't available in browser (blank page, no error). Only if I run debug server on port 4562 I can see published files and download it. My uWSGI command: > > ```shell > uwsgi --socket 0.0.0.0:4562 --protocol=http --wsgi-file fhost.py --callable app > ``` it is happening with me too after uploading a file via terminal when i check the link in a browser , all i get is a blank page.....You got any solution so far?
mia closed this issue 2022-08-01 18:08:30 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mia/0x0#24
No description provided.