HI,
Use this code
-----------------------------
import mysql.connector
import time;
import serial;
from mysql.connector import Error
from mysql.connector import errorcode
ser = serial.Serial('COM3', 9600, timeout=0,parity=serial.PARITY_EVEN, rtscts=1)
try:
connection = mysql.connector.connect(host='localhost',
database='hupiot',
user='root',
password='hup')
cur = connection.cursor()
while True:
s=ser.read();
print(s);
time.sleep(1);
sql=("INSERT INTO timerecord (userid, recordtime, userrole ) VALUES (%s,%s,%s)")
val=("1",s,"1")
if s=="9":
cur.execute(sql,val)
connection.close()
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
Nicely written and great information.
ReplyDeleteWe are technology/news/smartphone company, If you want to read such useful news then, Visit us: https://techmie.com/
Si Contact Form Plugin using for captcha to setup contact form in get it proper way it make properly
ReplyDeleteWoocommerce Floating Cart setup in woocommerce side cart in your ecommerce website
ReplyDeleteFrequently Bought Together For Woocommerce making to you can bought combo product in woocommerce with good discount in your website
ReplyDeleteCalculated Fields Form WordPress Plugin In Calculate Field to each other we can use wordpress plugin for calculation. let We explain you how to make Calculation Field in wordpress.
ReplyDeletePhoenix Binary System is a professional Website Development Company in Anand Gujarat. Mobile App, SEO company in Anand, Web Design Company in Surat.
ReplyDeleteAI Patasala Python Course in Hyderabad is sure to be the ideal choice for those looking to gain insight into all the real-world challenges in this field. AI Patasala Python course is the best option for students to begin their career with the latest technology.
ReplyDeleteAI Patasala Python Course