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

sqlite3.OperationalError: no such table: conceptscheme #890

Open
mielvds opened this issue Jul 9, 2024 · 5 comments
Open

sqlite3.OperationalError: no such table: conceptscheme #890

mielvds opened this issue Jul 9, 2024 · 5 comments

Comments

@mielvds
Copy link
Contributor

mielvds commented Jul 9, 2024

I tried importing a skosfile with the following script:

wget https://raw.githubusercontent.com/viaacode/datamodels/main/description/production-method.skos.ttl
import_file production-method.skos.ttl https://data.hetarchief.be/id/production-method

However, I get the following database error:

0.104 Connecting to raw.githubusercontent.com (185.199.108.133:443)                                                                                                                                                                            
0.322 saving to 'production-method.skos.ttl'                                                                                                                                                                                                   
0.322 production-method.sk 100% |********************************|  2233  0:00:00 ETA                                                                                                                                                          
0.322 'production-method.skos.ttl' saved
0.660 2024-07-09 07:45:19,286 INFO sqlalchemy.engine.Engine BEGIN (implicit)
0.661 2024-07-09 07:45:19,287 INFO sqlalchemy.engine.Engine INSERT INTO conceptscheme (uri) VALUES (?)
0.661 2024-07-09 07:45:19,287 INFO sqlalchemy.engine.Engine [generated in 0.00010s] ('https://data.hetarchief.be/id/production-method',)
0.661 2024-07-09 07:45:19,287 INFO sqlalchemy.engine.Engine ROLLBACK
0.661 Traceback (most recent call last):
0.661   File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
0.661     self.dialect.do_execute(
0.661   File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 924, in do_execute
0.661     cursor.execute(statement, parameters)
0.661 sqlite3.OperationalError: no such table: conceptscheme

@goessebr
Copy link
Contributor

goessebr commented Jul 9, 2024

I was able to fix it in my scaffold by specifying a target database. The default database is atramhasis.sqlite. I named my database atramhasis_scaffold.sqlite and I got the same error as you did.
Fixed import for a dabase named atramhasis_scaffold.sqlite: import_file production-method.skos.ttl https://data.hetarchief.be/id/production-method --to sqlite:///atramhasis_scaffold.sqlite

Perhaps we should make the database a required property and not use a default database. Alternatively, there should be a clearer message. Any preference?

/cc @koenedaele @Wim-De-Clercq, @mielvds

@koenedaele
Copy link
Member

Seems like using a default database is more harmful than helpful here, so I'm fine with making it a required property. Open to other suggestions as well.

@mielvds
Copy link
Contributor Author

mielvds commented Jul 10, 2024

I would suggest to have a better error message and/or a log message that clarifies what database it's using. If so, it is not really necessary to require this property (and I would do this either way).

@koenedaele
Copy link
Member

So, when importing a skos file, print a message similar to "Importing file {file} to database {database}"

Also, perhaps check if the database actually exists. I wonder if the database exists but is empty (because the migrations haven't run yet) or it doesn't exist and gets created on the fly.

@goessebr
Copy link
Contributor

There is one other issue when using import_file production-method.skos.ttl https://data.hetarchief.be/id/production-method --to sqlite:///atramhasis_scaffold.sqlite.

Due to this validator, it is not possible to address the endpoint /providers/. The second argument https://data.hetarchief.be/id/production-method is not a valid uri_pattern. It would be beneficial to validate the uri_pattern for a valid input.

A valid import would look like this:

wget https://raw.githubusercontent.com/viaacode/datamodels/main/description/production-method.skos.ttl
import_file production-method.skos.ttl https://data.hetarchief.be/id/production-method/%s --to sqlite:///atramhasis_scaffold.sqlite

Scope:

  • when importing a skos file, print a message similar to "Importing file {file} to database {database}"
  • check if database exists: if not, print an error message
  • check if database is not empty, if empty, print an error message
  • check if uri_pattern is valid, if not print an error message

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

No branches or pull requests

3 participants