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

Issues using DataTableAccess (rookie issue) #33

Open
SofusNL opened this issue Apr 2, 2024 · 4 comments
Open

Issues using DataTableAccess (rookie issue) #33

SofusNL opened this issue Apr 2, 2024 · 4 comments

Comments

@SofusNL
Copy link

SofusNL commented Apr 2, 2024

Hello.
I have previously used both mikeio and mikeio1D with great succes. I am now trying to get started using mikepluspy following the examples on here. I simply run the code below, which causes the error also seen below.
I am using anaconda + spyder (Python 3.11), which hasn't caused any issues with mikeio and mikeio1D, when installing using pip in the anaconda prompt. Similarly I am using mike+ 2024 for both mikepluspy and mike+.

import mikeplus
from mikeplus import DataTableAccess
from mikeplus.engines import Engine1D
import clr
import os

dta = DataTableAccess(test.sqlite)
dta.open_database()
dta.is_database_open()

Which results in the error:
SQLiteException: code = Error (1), message = System.Data.SQLite.SQLiteException (0x800007BF): SQL logic error
The specified module could not be found.
at DHI.Amelia.DataModule.Services.DataSource.DataSourceSpatiaLite.OpenDatabaseCore()
at DHI.Amelia.DataModule.Services.DataSource.BaseDataSource.OpenDatabase()

I have tried also including the following, which did not help, as well as trying to clr.AddReference() the two modules above, but perhaps that doesn't make sense, at least it did not work.
clr.AddReference("System")
clr.AddReference("System.Runtime")
clr.AddReference("System.Threading")
clr.AddReference("System.Runtime.InteropServices")
clr.AddReference("DHI.Amelia.DataModule")
clr.AddReference("DHI.Amelia.DataModule.Interface")
clr.AddReference("DHI.Amelia.Infrastructure.Interface")
clr.AddReference("DHI.Amelia.GlobalUtility")
clr.AddReference("DHI.Amelia.DomainServices")
clr.AddReference("DHI.Amelia.DomainServices.Interface")

I hope this is the correct place to post my issues, otherwise feel free to direct my to another place.

@wuwwen
Copy link
Collaborator

wuwwen commented Apr 8, 2024

This exception happens when the MIKE+ version is conflict or the database file path is invalid.
I think you can try two things.

  1. use absolute path for the sqlite file path.
  2. try to use jupyter notebook to run our example "notebooks/DataTableAccessor.ipynb"

@SofusNL

If there are still no progress, I'll check it further.

@SofusNL
Copy link
Author

SofusNL commented Apr 9, 2024

Hi @wuwwen thanks for looking at my problem.
I previously had both the 2023 and 2024 versions of MIKE+ installed. I deinstalled v.2023 from PC as I was afraid this might be causing the hickup, unfortunately this didn't work. Is it possible that there are still some remnants of the old version causing issues?
I have now also tried to use mikepluspy on a colleague's PC, but it did not work there either.

I have tried to use the absolute path, both using the classic "file_path=os.path.join(folder_path, file_name)" and also just raw typing the entire thing into DataTableAccess(...), but neither worked.

I hope this can narrow the issue down further.

@wuwwen
Copy link
Collaborator

wuwwen commented Jun 5, 2024

@SofusNL How are you doing here? We can't reproduce your issue on our side. That why there is no fix for the time being.
What we have done is below:

  1. Created env by using conda.
  2. Installed all the necessary libs (numpy, pandas, python 11)
  3. Installed MIKE+ 2024
  4. Install mikepluspy package by using "pip install https://github.com/DHI/mikepluspy/archive/refs/tags/v2024.0-latest.zip"
  5. Open Spyder to execute below code. It can open the database successfully. Please remember to use the new created env in Spyder.
    from mikeplus import DataTableAccess
    data_access = DataTableAccess("example.sqlite")
    data_access.open_database()
    data_access.close_database()
    print("Sqlite database opened successed.")

Anything missing in our steps?

@SofusNL
Copy link
Author

SofusNL commented Jun 5, 2024 via email

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