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

sql extension error #699

Closed
wck01 opened this issue Jul 5, 2017 · 7 comments
Closed

sql extension error #699

wck01 opened this issue Jul 5, 2017 · 7 comments
Milestone

Comments

@wck01
Copy link

wck01 commented Jul 5, 2017

I installed the latest version v0.11.1. I try to use sql() function in Excel and got the below error. Any idea to solve it?

No command specified in the configuration, cannot autostart server

@fzumstein
Copy link
Member

Make sure you have a correct interpreter set, maybe try a RunPython sample first (based on quickstart).

@wck01
Copy link
Author

wck01 commented Jul 5, 2017

Hi fzumstein,

Thanks for your comments. Now, I have correct setup with quickstart and can run double_sum function (as quickstart). However, when I try the sql function like "=sql("SELECT a.x from a",A1:B3)". I got the below error:

"OperationalError: no such table: a
c.execute(query)
File ""C:\Users\xxxxxx\AppData\Local\Continuum\Anaconda2\lib\site-packages\xlwings\ext\sql.py"", line 53, in sql
ret = func(*args)
File ""C:\Users\xxxxxx\AppData\Local\Continuum\Anaconda2\lib\site-packages\xlwings\udfs.py"", line 250, in call_udf
res = call_udf(script, fname, args, this_workbook, FromVariant(caller))
File ""C:\Users\xxxxxx\AppData\Local\Continuum\Anaconda2\lib\site-packages\xlwings\server.py"", line 190, in CallUDF
return func(*args)
File ""C:\Users\xxxxxx\AppData\Local\Continuum\Anaconda2\lib\site-packages\win32com\server\policy.py"", line 585, in invokeex
return S_OK, -1, self.invokeex(dispid, lcid, wFlags, args, None, None)
File ""C:\Users\xxxxxx\AppData\Local\Continuum\Anaconda2\lib\site-packages\win32com\server\policy.py"", line 282, in invoke
return self.invoke(dispid, lcid, wFlags, args)
File ""C:\Users\xxxxxx\AppData\Local\Continuum\Anaconda2\lib\site-packages\win32com\server\policy.py"", line 277, in Invoke"

@fzumstein
Copy link
Member

is it possible that you don't use , as the seperator of arguments in your settings of excel? maybe try ; instead?

@wck01
Copy link
Author

wck01 commented Jul 5, 2017

I don't think this is the separator issue. When I try "=sql("select * from B",A1:B10)", it works.

@fzumstein
Copy link
Member

Can you attach your spreadsheet here please?

@wck01
Copy link
Author

wck01 commented Jul 5, 2017

Sure. The file is attached.

myproject.zip

@wck01
Copy link
Author

wck01 commented Jul 5, 2017

I think I found out what's wrong.

When I use "=sql("select * from B",A1:B10)", it works.
When I use "=sql("select * from C",A1:C10)", it works.

It seems that the table name depends on the table columns I selected.

I check sql.py. It seems that the index "i" is repeated to be used.

**for i, table in enumerate(tables):
    cols = table[0]
    rows = table[1:]
    types = [
        any(type(row[i]) is str for row in rows)
        for i in range(len(cols))
    ]
    name = chr(65 + i)

When I change "for i in range(len(cols))" to "for x in range(len(cols))", it runs as the docs. It's prefect now.

Thanks for the great tool.

fzumstein added a commit that referenced this issue Jul 5, 2017
@fzumstein fzumstein modified the milestone: v0.11.2 Jul 5, 2017
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