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

SQL statement results in error message with MySQL/MariaDB #5

Closed
roe-dl opened this issue Mar 11, 2021 · 1 comment
Closed

SQL statement results in error message with MySQL/MariaDB #5

roe-dl opened this issue Mar 11, 2021 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@roe-dl
Copy link
Owner

roe-dl commented Mar 11, 2021

            _result = db_manager.getSql(
                    "SELECT SUM(radiation*interval)/60.0, "
                    "MIN(usUnits), MAX(usUnits) FROM %s "
                    "WHERE dateTime >? AND dateTime<=?"
                    % db_manager.table_name, timespan)

results in

Mar 11 09:20:26 hesba weewx[16349] ERROR weewx.reportengine:         ****  weedb.DatabaseError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')/60.0, MIN(usUnits),MAX(usUnits) FROM archive WHERE dateTime>1612825200 AND ...' at line 1")

for MySQL/MariaDB.

@roe-dl roe-dl added bug Something isn't working help wanted Extra attention is needed labels Mar 11, 2021
@roe-dl
Copy link
Owner Author

roe-dl commented Mar 11, 2021

According to Gary 'interval' is a reserved word in MySQL and therefore needs to be enclosed in backticks (not single quotes).

commit 69cc037

@roe-dl roe-dl closed this as completed Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant