-
Notifications
You must be signed in to change notification settings - Fork 11
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
Doesn't work with MariaDB #3
Comments
Thank you for your feedback, and thanks for using django-probes in the first place! 🥇 Would you want to try placing a pull request for the change? I would suggest to start with extending the test setup in a way that it covers more databases. Currently, only Postgres is tested against, which is apparently not enough. 😟 |
Hi.
How do you propose to add a database-specific code? |
The idea of this package is to be database independent. Ideally, we only add tests that prove that currently the code only works for Postgres and fails for MariaDB. Then we adapt the code to make it work for both database engines. Same for other engines, in future.
Do you think you can do this? |
We could try, it would be interesting. But I ask about a different thing. How to run a raw SQL depend on backend? |
You make this dependent on your Django settings. Set the appropriate backend in your settings, then the SQL query will run against that specific DBMS. |
No, i know this. I am talking about this piece of code:
How to say? if "MariaDB":
connection.cursor().execute('SELECT 1')
elif "Postgres":
connection.cursor().execute('SELECT')
else:
raise Exception("Not supported backend.) # Just as an example |
I just realized that I could try to read settings and compare.
But quick search showed another way:
|
On StackOverflow, I have found a list with all ping queries. We could try to use it for extending a list of supported backends. |
Wow, this is very helpful, cool! 🥇 So, we can use the appropriate ping query for the chosen database engine. That is one reason more to add additional tests for the different supported database engines. 👍 Side note:What is also not yet supported is multiple databases. I have created a separate ticket (#4) for that. |
Use 'SELECT 1', it's the more compatible. This works on most commonly used databases, like postgreSQL, mysql, mariadb, mssql (and probably others). But does _not_ work on, for example, oracle (and probably others). This is a, minimal impact, 'quick fix', better solution would be to go through Django's database backend 'is_usable' method. Fixes issue painless-software#3
Use 'SELECT 1', it's the more compatible. This works on most commonly used databases, like postgreSQL, mysql, mariadb, mssql (and probably others). But does _not_ work on, for example, oracle (and probably others). This is a, minimal impact, 'quick fix', better solution would be to go through Django's database backend 'is_usable' method. Fixes issue #3
This should work now with version 1.3.0 released last week. 🚀 Thanks for your valuable input! 🥇 |
Hi.
I must thank you for this amazing project! But it seems doesn't work with MariaDB. I tried with several versions: 5.5, 10.1, 10.3 and 10.4. Always the same result.
Note. I have moved your command inside my project to be able to fix it. So, don't look at the path. Code is absolutely the same.
It seems like
connection.cursor().execute('SELECT')
doesn't wotk for MariaDB. Butconnection.cursor().execute('SELECT 1')
does. What do you think?The text was updated successfully, but these errors were encountered: