Kamis, 28 Oktober 2021

Raspi Insatall dan Koneksi Database New

UPDATE:

sudo apt-get update && sudo apt-get upgrade


RASPI INSATLL DATABASE SERVER:

sudo apt-get install python3-dev libmysqlclient-dev
sudo pip3 install mysqlclient

ATAU

sudo apt-get install python3-dev **default-libmysqlclient-dev**

sudo pip3 install mysqlclient


INSTALL PIP3

sudo python3-pip


INSTALL CV2

sudo apt update

sudo apt install python3-opencv


CONFIG CAMERA DLL

sudo raspi-config
df -h
sudo reboot


LCD:

 sudo raspi-config

 sudo apt-get install i2c-tools

 sudo apt-get install python-smbus

 i2cdetect -y 1

 

import MySQLdb
from time import sleep
db = MySQLdb.connect("localhost","root","","2021_deteksicitra")
cursor = db.cursor()
sql = "UPDATE `tb_pengujian`  set `status`='1',`rekapitulasi`='%s',`bobot`='%s',`kategori`='%s' where id_pengujian='%s'" % (rekapitulasi,bobot,kategori,idx)
#print(sql)
try:
cursor.execute(sql)
db.commit()
v=1
except:
db.rollback()
    db.close() 

while (True):
    ada=0
    db = MySQLdb.connect("localhost","root","","2021_deteksikentang")
    cursor = db.cursor()
    
    cursor.execute("SELECT `id_pengujian`, `nama_pengujian`, `gambar`,`status` FROM `tb_pengujian` where status='0' order by id_pengujian desc")
    for row in cursor.fetchall():
        ada=1
        id_pengujian=row[0]
        nama_pengujian=row[1]
        gambar=row[2]
        status=row[3]
        
        lokasi = PATH_UJI+gambar  
        print(lokasi)
        LoadCNN(lokasi,id_pengujian,rekapitulasi,bobot)
    time.sleep(1)
    db.close()

Tidak ada komentar:

Posting Komentar