-
Notifications
You must be signed in to change notification settings - Fork 4
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
Windows ODBC data source always uses :memory: no matter what you set it to in Control Panel - ODBC Data Sources #29
Comments
I have this issue as well on Windows 11 with the 64 bit drivers and power BI/Excel. Also noting that a couple of the tests are failing when I run test_odbc.exe that comes with the drivers. D:\a\duckdb\duckdb\tools\odbc\test\tests\connect.cpp(132): FAILED: Test SQLColAttribute for a query that returns an int =============================================================================== |
I also find this issue prevents from using window's version DuckDB ODBC Driver with a connection to database other than :memory:. Symptoms include empty list of tables displayed using FWIW I note this issue is surfacing elsewhere Might this help ??? ... I too found some of the tests failing:
and
success here:
I also installed bleeding edge from https://duckdb.org/docs/installation/?version=main&environment=odbc&platform=win&download_method=direct&architecture=x86_64 and found this issue persists. |
Follow up with a hint and possible step toward a workaround...
I put the following in as the SQL statement:
and I got a step further as ...however when I click on "Load" I am advised: |
If you edit your query and click "Advanced Editor" I believe the following would give you what you expect:
It should not be necessary to specify the location of the file, of course. But right now that's what I do, under the circumstances. |
@shwivel thanks for that tip - i saw it before too in duckdb/duckdb#11380 (comment) - I just don't know how to apply it to my use of Excel, as opposed to your use of Power Query. Guidance much appreciated! |
You are in the correct place. On the very first screen (depicted below) you would separate the connection string and query as depicted below: Later, it is helpful for formatting purposes to use the advanced editor. (ribbon menu > Data > Queryies & Connections [this opens a side panel on the right with all your queries] then right click your query (from that side panel), click edit, and in the window that pops up, use the "Advanced Editor" button on the top left of ribbon menu. Then you'll see what I had pasted above and can more easily tweak the connection string and query. (still easier to to copy and paste from a syntax editor, but at least you get the line breaks and such) This looks like hell compared to the equivalent functionality on Google Sheets, but it is what it is and is mostly not terrible. Not as good as it could be, for sure. |
Thanks @shwivel - I'm so close! Using your suggestion, I'm now getting this error message: ... whether or not I qualify the table name with I'm pretty confident I am connecting to my database since if I mistype the database path the error message instead refers to :memory:. I am also confident my select statement is correct - it works when run connecting using CLI (linux side), with or without the Do you possibly see any other variation I should be trying? |
If you go to the advanced editor (where the first word should be "let") you see a connection string and your query in the format depicted here, correct? #29 (comment) Are you attaching databases (within SQL) or solely using the database you've specified in the connection string? What happens if you just run a query like:
To confirm for certain you are connecting to the correct .db file you could also run this query:
Should return a value of something like "c:\your_path\your_name.your_extension.tmp" (the db file you're connecting to, with .tmp added at the end). If you don't see that, and you see merely ".tmp" that means you've connected to :memory: |
By default the temp file will be in the same folder as the database file (that you're connected to), and the temp file will be named the same, but with .tmp at the end. If you've connected to :memory: then the result will just be .tmp. You mention having running that test query via CLI on a linux machine, but that's not where you need to test because it is not where you're having trouble connecting. I would test out running that query in Excel (rather than the query you're actually running) to make sure that you're actually connecting to the database you want to connect to, within Excel. Attached is an Excel file named test_excel.xlsx with a query that accesses a database named testdb.db at path C:\data\testdb.db which has one table called poo. An image below depicts the setup. Excel file: Database file: If you put the database file onto your Windows machine at path C:\data\ and this Excel file will not allow you to refresh the query result, then something is going on environment-wise, because I can do so, with these two files. |
FWIW: my workaround for now is to mirror the duckdb in sqlite for purposes of slapping an excel data dashboard in front of it. 😄 |
Alas: the issue persists for me on two other windows computers. re: environment-wise possibilities - I retested after installing latest supported Microsoft Visual C++ Redistributable (and restarting). No fix 😢 Still hoping this issue just gets fixed upstream... |
On a Windows system after installing the ODBC driver a data source name of "DuckDB" is created with the default database set to :memory: but of course we may wish to specify a specific database file.
When you change :memory: to some file (ie. C:\some_file.db ) and you try to use that data source, you'll get "table not found" errors (if running a query) or no tables will list (if listing tables) because it's actually using the transient :memory: database even though you've specified a persistent one, as depicted below:
It shows up in regedit fine:
But it doesn't actually use the given database. For example if you open Excel or Power BI and click Data > Get Data > From other sources > From ODBC > DuckDB > no tables will be listed because none are there (it's using :memory: and not the one specified in Control Panel > ODBC data sources). You can manually set the database file location and get the tables to list, within every Excel or whatever file using the DSN, however this is not only annoying to have to do everywhere and every time, but certain features become limited when you set a manual connection string. In any case, I figure this cannot be intended, because why would you allow the specification of a database (with a default of :memory:) if no matter what you change it to, it is still going to use :memoy:?
Let me know if you have any questions. Thanks
The text was updated successfully, but these errors were encountered: