资源简介

物联网Python开发实战书的源代码

资源截图

代码片段和文件信息

#!/usr/bin/env python
import pymysql  #Python3
 
db = pymysql.connect(“localhost““sips““root““zaijian“ )
cursor = db.cursor()
cursor.execute(“SELECT VERSION()“)
data = cursor.fetchone()
 
print (“Database version : %s “ % data)
db.close()

def create_table():
 db = pymysql.connect(“localhost““sips““root““zaijian“ )
  cursor = db.cursor()
  cursor.execute(“DROP TABLE IF EXISTS EMPLOYEE“)
  sql = “““CREATE TABLE EMPLOYEE (
         FIRST_NAME  CHAR(20) NOT NULL
         LAST_NAME  CHAR(20)
         AGE INT  
         SEX CHAR(1)
         INCOME FLOAT )“““

  cursor.execute(sql)
  db.close()
  
def db_insert():
  db = pymysql.connect(“localhost““sips““root““zaijian“ )
  cursor = db.cursor()
  sql = “““INSERT INTO EMPLOYEE(FIRST_NAME
         LAST_NAME AGE SEX INCOME)
         VALUES (‘Mac‘ ‘Mohan‘ 20 ‘M‘ 2000)“““

  try:
    cursor.execute(sql)
    db.commit()
  except:
    db.rollback()
  db.close()

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-03-21 01:14  Smart-IoT-Planting-System-master\
     文件        1157  2018-03-21 01:14  Smart-IoT-Planting-System-master\.gitignore
     文件        1063  2018-03-21 01:14  Smart-IoT-Planting-System-master\LICENSE
     文件        1890  2018-03-21 01:14  Smart-IoT-Planting-System-master\README.md
     目录           0  2018-03-21 01:14  Smart-IoT-Planting-System-master\arch\
     文件      150608  2018-03-21 01:14  Smart-IoT-Planting-System-master\arch\Hardware-kit-1.jpg
     文件      135863  2018-03-21 01:14  Smart-IoT-Planting-System-master\arch\Hardware-kit-2.jpg
     文件          32  2018-03-21 01:14  Smart-IoT-Planting-System-master\arch\README.md
     文件       33075  2018-03-21 01:14  Smart-IoT-Planting-System-master\arch\arch-diagram.png
     文件       80509  2018-03-21 01:14  Smart-IoT-Planting-System-master\arch\environment.png
     目录           0  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\
     文件        1688  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\README.md
     文件         932  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\database.py
     目录           0  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\db\
     文件         932  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\db\db.py
     文件          59  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\db\db_init.sh
     目录           0  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\deploy\
     文件         222  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\deploy\README.md
     文件         610  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\deploy\cloud_deploy.sh
     文件          44  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\echarts-python.py
     目录           0  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\mqtt_server\
     文件         192  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\mqtt_server\REAMDE.md
     文件          55  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\mqtt_server\hbmqtt_server.sh
     文件         726  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\mqtt_server\pub.py
     文件         835  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\mqtt_server\sub.py
     目录           0  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\platform\
     文件         393  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\platform\README.md
     目录           0  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\platform\sips\
     文件          86  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\platform\sips\db_init.sh
     文件          48  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\platform\sips\deploy.sh
     文件         802  2018-03-21 01:14  Smart-IoT-Planting-System-master\cloud\platform\sips\manage.py
............此处省略88个文件信息

评论

共有 条评论