kandi background

allsky | A Raspberry Pi operated Wireless Allsky Camera

Download this library from

kandi X-RAY | allsky Summary

allsky is a C++ library typically used in Internet of Things (IoT), Raspberry Pi applications. allsky has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.
This is the source code for the Allsky Camera project described on Instructables.

kandi-support Support

  • allsky has a low active ecosystem.
  • It has 387 star(s) with 123 fork(s). There are 44 watchers for this library.
  • There were 1 major release(s) in the last 6 months.
  • There are 51 open issues and 592 have been closed. On average issues are closed in 29 days. There are 3 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of allsky is v2022.03.01

quality kandi Quality

  • allsky has 0 bugs and 0 code smells.

securitySecurity

  • allsky has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • allsky code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license License

  • allsky is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.

buildReuse

  • allsky releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

allsky Key Features

A Raspberry Pi operated Wireless Allsky Camera

allsky Examples and Code Snippets

  • Software Installation
  • Autostart
  • Manual Start
  • Web User Interface (WebUI)
  • Timelapse
  • Automatic deletion of old data
  • Logging issues
  • On the Pi
  • Error 1064 (42000): error in your SQL syntax ... near ' '

Software Installation

sudo apt-get install git

Community Discussions

Trending Discussions on allsky
  • Error 1064 (42000): error in your SQL syntax ... near ' '
Trending Discussions on allsky

QUESTION

Error 1064 (42000): error in your SQL syntax ... near ' '

Asked 2021-May-29 at 12:33

I'm stuck since a couple days and tried most of the answer given to similar questions on this site.

Before starting I'd like to point out that I am working via ssh and can only edit the code via nano (not my choice...)

My problem is the following:

I am using MariaDB to store the raspberry pi CPU temperature along a camera temperature to plot the temperature evolution. I have an error when trying to insert the values in the data base.

I have the following table in cpu_tempDB

MariaDB [cpu_tempDB]> show columns from CPU_TEMP_TABLE;
+-------------+--------------+------+-----+---------------------+----------------+
| Field       | Type         | Null | Key | Default             | Extra          |
+-------------+--------------+------+-----+---------------------+----------------+
| ID          | bigint(20)   | NO   | PRI | NULL                | auto_increment |
| CPU_TEMP    | decimal(6,2) | NO   |     | NULL                |                |
| CREATED     | timestamp    | NO   |     | current_timestamp() |                |
| CAMERA_TEMP | decimal(6,2) | NO   |     | 0.00                |                |
+-------------+--------------+------+-----+---------------------+----------------+

In my python code I use the following functions:

from gpiozero import CPUTemperature
import mysql.connector as mariadb

# get CPU temperature in Celsius
cpu = CPUTemperature()
cpu_temp = cpu.temperature

# get Camera temperature in Celsius
tempfile = open("/home/pi/allsky/temperature.txt","r")
cam_temp = tempfile.read().rstrip()

# make a new mariaDB entry and retrieve old values
try:
   # open connection
   mariadb_connection = mariadb.connect(host= "localhost", user="pi", password="--Sensored--", database="cpu_tempDB")
   cursor = mariadb_connection.cursor()
   # upload
   sql = "insert into CPU_TEMP_TABLE (CPU_TEMP, CAMERA_TEMP) values (%s, %s)"
   args = cpu_temp, float(cam_temp)
   cursor.execute(sql,args)
   mariadb_connection.commit()
   # fetch
   cursor.execute("select * from CPU_TEMP_TABLE where CPU_TEMP_TABLE.CREATED > DATE_SUB(NOW(), INTERVAL 7 DAY")
   records = cursor.fetchall()
except mariadb.Error as e:
   print("Error writing cpu temp to mariaDB:",e)
finally:
   mariadb_connection.close()
   cursor.close()
# store data in lists
time_list = []
cpu_temp_list = []

for row in records:
  cpu_temp_list.append(row[1])
  time_list.append(row[2])

# declare date formatter for plot
myFmt = mdates.DateFormatter('%H:%M')

# generate plot
mpl.use('Agg')


plt.plot(time_list, cpu_temp_list, 'b-')
plt.xlabel('Time')
plt.ylabel('CPU Temperature [°C]')
plt.title('CPU Temperature evolution over the last 48 hours')
plt.gca().xaxis.set_major_formatter(myFmt)

# save plot
plt.savefig('cpu_temp.png')

I get the following error :

Error writing cpu temp to mariaDB: 1064 (42000): 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 '' at line 1
Traceback (most recent call last):
  File "CPU_temp.py", line 45, in <module>
    for row in records:
NameError: name 'records' is not defined

EDIT: I added a print(sql, args) before the error, here's the console print

insert into CPU_TEMP_TABLE (CPU_TEMP, CAMERA_TEMP) values (%s, %s) (64.27, 58.2)

EDIT 2: added the rest of the code as some of you mentioned that error warning where displayed outside the shown code

EDIT 3: restarted from 0 and now it works... I cannot delete this post unfortunately

ANSWER

Answered 2021-May-29 at 08:58

You need to put arguments into a tuple:

sql = "insert into CPU_TEMP_TABLE (CPU_TEMP, CAMERA_TEMP) values (%s, %s)"
args = (cpu_temp, float(cam_temp),)
cursor.execute(sql,args)

Or to construct a string in-place:

sql = "insert into CPU_TEMP_TABLE (CPU_TEMP, CAMERA_TEMP)
    values (%s, %s)" % (cpu_temp, float(cam_temp),)
cursor.execute(sql)

Source https://stackoverflow.com/questions/67749404

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install allsky

PatriotAstro created a video describing the installation steps below. Feel free to check it out. Another video covers the installation on a Raspberry Pi zero with both ZWO and RPiHQ cameras. You will need to install the Raspbian Operating System on your Raspberry Pi. Follow this link for information on how to do it. Make sure you have a working internet connection by setting it through the terminal. NOTE: Version 0.8 added many new settings and changed the name of several existing settings. For example, there are now separate brightness levels for daytime and nighttime, called "daybrightness" and "nightbrightness". Version 0.7 only had "brightness" that applied to both day and nighttime. It's very important that you save a copy of your current settings prior to upgrading to version 0.8 so you can restore them properly. The WebUI from the allsky-portal package uses these new settings so it's also important to update AllSky prior to updating the WebUI. Also note that in version 0.8.3 the default image file created and uploaded is called "image.jpg". The prior "image-resize.jpg" and "liveview-image.jpg" are no longer created. Keep that in mind if you copy the image to a remote web server - it will need to know about the new name. Some users have reported ASI_ERROR_TIMEOUT errors with their ZWO cameras in verion 0.8. Click here to troubleshoot.
Start by installing git if not already there. Open the terminal and type the following: sudo apt-get install git
Now fetch the code from this GitHub page: git clone --recursive https://github.com/thomasjacquin/allsky.git
Then navigate to the allsky directory: cd allsky
Now, run the install script: ./install.sh # PatriotAstro's video shows using "sudo"; that is no longer needed

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Build your Application

Share this kandi XRay Report