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

"Exception: No suitable database adapter found!" for package examples #31

Open
juso opened this issue Apr 12, 2018 · 21 comments
Open

"Exception: No suitable database adapter found!" for package examples #31

juso opened this issue Apr 12, 2018 · 21 comments

Comments

@juso
Copy link

juso commented Apr 12, 2018

While running flask-excel examples (database_example.py and database_example_formatted.py) in python3 on Windows face with the above exception. Will try on linux and report here as well

@juso
Copy link
Author

juso commented Apr 12, 2018

checked on Linux (Ubuntu on Win10) - same behavior

@chfw
Copy link
Member

chfw commented Apr 12, 2018

any further information? I have just tried the database_example.py and it works as expected.

@juso
Copy link
Author

juso commented Apr 12, 2018

I'm running on python 3.5.2. Which version you run it on?

@chfw
Copy link
Member

chfw commented Apr 12, 2018

I used python 2.7

@juso
Copy link
Author

juso commented Apr 12, 2018

Here is the log
(env) yyy@FThi:~/projects/test.flask-excel$ python database_example.py

  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 340-127-841
    127.0.0.1 - - [12/Apr/2018 16:32:25] "GET /import HTTP/1.1" 200 -
    127.0.0.1 - - [12/Apr/2018 16:32:30] "POST /import HTTP/1.1" 500 -
    Traceback (most recent call last):
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/app.py", line 1997, in call
    return self.wsgi_app(environ, start_response)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functionsrule.endpoint
    File "/home/yuryf/projects/test.flask-excel/database_example.py", line 101, in doimport
    initializers=[category_init_func, post_init_func])
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel_webio/init.py", line 237, in save_book_to_database
    pe.save_book_as(**params)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel/core.py", line 99, in save_book_as
    return sources.save_book(book, **dest_keywords)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel/internal/core.py", line 51, in save_book
    return _save_any(a_source, book)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel/internal/core.py", line 55, in _save_any
    a_source.write_data(instance)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel/plugins/sources/db_sources.py", line 103, in write_data
    **self._keywords)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel/plugins/renderers/sqlalchemy.py", line 56, in render_book_to_stream
    save_data(importer, to_store, file_type=self._file_type, **keywords)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel_io/io.py", line 119, in save_data
    **keywords)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel_io/io.py", line 141, in store_data
    writer.write(data)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel_io/book.py", line 210, in write
    sheet_writer = self.create_sheet(sheet_name)
    File "/home/yuryf/projects/test.flask-excel/env/lib/python3.5/site-packages/pyexcel_io/database/importers/sqlalchemy.py", line 92, in create_sheet
    raise Exception("No suitable database adapter found!")
    Exception: No suitable database adapter found!

@juso juso changed the title "Exception: No suitable database adapter found!" for package examplces "Exception: No suitable database adapter found!" for package examples Apr 12, 2018
@chfw
Copy link
Member

chfw commented Apr 12, 2018

I tried again with 3.6.3 on import use case. Worked for me.

@chfw
Copy link
Member

chfw commented Apr 12, 2018

Let me try it on py 3.5.2

@juso
Copy link
Author

juso commented Apr 12, 2018

It's strange, it doesn't work on 2.7.12 either, not sure what is the catch. Cannot imagine what can be wrong similar way on both Win and Linux.

Here is the log:

(env2) yuryf@FThi:~/projects/test.flask-excel$ python ./database_example.py

  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 122-577-823
    127.0.0.1 - - [12/Apr/2018 18:36:42] "GET /import HTTP/1.1" 200 -
    127.0.0.1 - - [12/Apr/2018 18:36:47] "POST /import HTTP/1.1" 500 -
    Traceback (most recent call last):
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/flask/app.py", line 1997, in call
    return self.wsgi_app(environ, start_response)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functionsrule.endpoint
    File "/home/yuryf/projects/test.flask-excel/database_example.py", line 101, in doimport
    initializers=[category_init_func, post_init_func])
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel_webio/init.py", line 237, in save_book_to_database
    pe.save_book_as(**params)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel/core.py", line 99, in save_book_as
    return sources.save_book(book, **dest_keywords)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel/internal/core.py", line 51, in save_book
    return _save_any(a_source, book)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel/internal/core.py", line 55, in _save_any
    a_source.write_data(instance)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel/plugins/sources/db_sources.py", line 103, in write_data
    **self._keywords)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel/plugins/renderers/sqlalchemy.py", line 56, in render_book_to_stream
    save_data(importer, to_store, file_type=self._file_type, **keywords)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel_io/io.py", line 119, in save_data
    **keywords)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel_io/io.py", line 141, in store_data
    writer.write(data)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel_io/book.py", line 210, in write
    sheet_writer = self.create_sheet(sheet_name)
    File "/home/yuryf/projects/test.flask-excel/env2/lib/python2.7/site-packages/pyexcel_io/database/importers/sqlalchemy.py", line 92, in create_sheet
    raise Exception("No suitable database adapter found!")
    Exception: No suitable database adapter found!

@juso
Copy link
Author

juso commented Apr 12, 2018

have integrated the code from 'database_example_formatted.py' into the existing project on 3.5.2 working with MySQL, and still get the same exception. The rest of the project works fine with the db, so very curious on what it could be.

@chfw
Copy link
Member

chfw commented Apr 12, 2018

The nature of the exception is your book got more sheets than the number of tables to be imported.

@juso
Copy link
Author

juso commented Apr 12, 2018

I'm running the example 'database_example_formatted.py' with (what I assume it is) test data file 'example_for_upload.csv' from the same git directory. Shall I use something else?

@chfw
Copy link
Member

chfw commented Apr 13, 2018

You should use sample.xls

@juso
Copy link
Author

juso commented Apr 13, 2018

Where can I take it or shall I create my own? If I need to create own then is there any logic of the content I need to follow? Number of sheets, number of columns on each sheet, headers etc.?

@juso
Copy link
Author

juso commented Apr 13, 2018

created my own version https://www.dropbox.com/s/zbzpr368l88re8n/sample.xlsx?dl=0 but no luck so far, still same exception. Also tried this version without column headers, but still same result.

@juso
Copy link
Author

juso commented Apr 13, 2018

Thank you very much for your support @chfw , finally I've figured out things about example code and was able to run it without issues. Probably would make sense to add a note somewhere in the readme that the file sample-data.xls should be used as input and it's located in the root of the project.

May also make sense to note packages pyexcel-xlsx, pyexcel-xls and pyexcel-handsontable, which need to be installed in order to run the sample code smoothly.

Let me know if I have to close the issue or you'd prefer to do it yourself

@chfw
Copy link
Member

chfw commented Apr 13, 2018

I will take your feedback and then close this issue. Thanks for trying.

@juso
Copy link
Author

juso commented Apr 13, 2018

Maybe one more comment - I'm now integrating with flask-excel, and again, getting the same exception. Now I'm sure there is something wrong with my code, but there is no way to figure out what's wrong other than trial&error approach, very time consuming. May make sense to make the error more meaningful so that developer can quickly understand what's wrong and fix it. Especially that this error doesn't sound like something to do with database adapter (maybe I'm wrong), it's more like a generic error)

@chfw
Copy link
Member

chfw commented Apr 13, 2018

OK. I will update the error too. The exception says: if you got three sheets in a book but you have only given 2 tables, the third dangling one will not be handled hence the error try to flag it up.

@juso
Copy link
Author

juso commented Apr 13, 2018

Not only that, it's also that the sheet name (in xls) and the table name (in db where the data is imported to) should match exactly. Class name maybe different though, despite a comment to the previous similar issue. At least this is my current finding

@juso juso closed this as completed Apr 13, 2018
@juso juso reopened this Apr 13, 2018
@juso
Copy link
Author

juso commented Apr 13, 2018

Sorry, closed by mistake

@chfw
Copy link
Member

chfw commented Apr 13, 2018

I see. I will point it out in the exception too. I am sorry for the mis-leading error message which is not helpful and requires my interpretation.

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

No branches or pull requests

2 participants