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

Cannot create model #77

Closed
radiantone opened this issue Oct 7, 2023 · 7 comments
Closed

Cannot create model #77

radiantone opened this issue Oct 7, 2023 · 7 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@radiantone
Copy link

Does this SDK work at all? Seems like its broken

Tried to create a model using a simple SQL query "select * from prices" and looks like its introducing parens or something.

  • Python version: 3.10.12

  • Operating system: Pop!_OS(Ubuntu) 22.04

  • Mindsdb Python SDK version:
    mindsdb-sdk==1.0.4
    mindsdb-sql==0.6.7

  • Additional info if applicable:

Please describe your issue and how we can replicate it

File "/home/darren/PycharmProjects/pyfi/pyfi/server/api.py", line 1747, in create_model
project.create_model(name=model, predict=data["column"], query=data['query'])
File "/home/darren/PycharmProjects/pyfi/venv/lib/python3.10/site-packages/mindsdb_sdk/project.py", line 410, in create_model
df = self.query(ast_query.to_string()).fetch()
File "/home/darren/PycharmProjects/pyfi/venv/lib/python3.10/site-packages/mindsdb_sdk/query.py", line 29, in fetch
return self.api.sql_query(self.sql, self.database)
File "/home/darren/PycharmProjects/pyfi/venv/lib/python3.10/site-packages/mindsdb_sdk/connectors/rest_api.py", line 11, in wrapper
return fnc(self, *args, **kwargs)
File "/home/darren/PycharmProjects/pyfi/venv/lib/python3.10/site-packages/mindsdb_sdk/connectors/rest_api.py", line 82, in sql_query
raise RuntimeError(data['error_message'])
RuntimeError: SQL statement cannot be parsed by mindsdb_sql - CREATE PREDICTOR modeltest (select * from prices) PREDICT prices: Syntax error at token LPAREN: "("

@ZoranPandovski
Copy link
Member

Can you share the code example please?

@ea-rus
Copy link
Contributor

ea-rus commented Oct 9, 2023

@radiantone, here is data['query'] a string?
project.create_model(name=model, predict=data["column"], query=data['query'])

If yes, you need to add 'database' param. If query have to be executed in context of mindsdb, please add database='mindsdb'. It should help

@tomhuds tomhuds added the bug Something isn't working label Oct 17, 2023
ea-rus added a commit that referenced this issue Oct 23, 2023
@ea-rus ea-rus added the question Further information is requested label Jan 15, 2024
@ea-rus
Copy link
Contributor

ea-rus commented Feb 5, 2024

Let's close it and open again when we have more information

@ea-rus ea-rus closed this as completed Feb 5, 2024
@kiuyaku
Copy link

kiuyaku commented Jul 10, 2024

Let's close it and open again when we have more information
@ea-rus

Hi sir, I can't create a model either, I get an error after using models.create.

  • Python version: 3.11
  • SDK version: 2.4.4
  • mindsdb container: mindsdb/mindsdb:cloud

ERROR:
“”“

CREATE PREDICTOR my_project.my_model (SELECT * FROM my_db.my_article) PREDICT id
----------------------------------------^
Expected symbol: "PREDICT"
”“”

I've looked for a lot of examples and issues that can't solve my problem.

Here's my code:
I want to use the default engine and insert my data to create a model.
Is the following usage correct? Or are there other steps?
Can you please help me see where the error is? Thank you sosososososososo much.

CODE
"""
project = server.get_project('my_project')
table = mysql_db.tables.get('my_article')
model = project.models.create(
'my_model',
predict='id',
query=table,
)
"""

@ea-rus
Copy link
Contributor

ea-rus commented Jul 10, 2024

@kiuyaku, please try to update mindsdb_sql to the latest version

@ea-rus
Copy link
Contributor

ea-rus commented Jul 10, 2024

This could be the cause: #129

@kiuyaku
Copy link

kiuyaku commented Jul 11, 2024

@kiuyaku, please try to update mindsdb_sql to the latest version

OK! thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants