将python中的MAC地址插入mysql

时间:2017-07-15 19:47:21

标签: python mysql

我最近想把bluetooth.discover_devices()的mac地址插入到mysql表中。
但我总是得到“你的SQL语法有错误;请在第1行查看与'MySQL:2D:A0:47:E4'附近的用户正确语法对应的MySQL服务器版本的手册“
我从bluetooth.discover_devices()获取的MAC地址为00:EE:2D:A0:47:E4。
我想知道为什么我不能存储使用python中的简单插入到mysql中 仅供参考,我已经尝试打印地址并显示我的MAC地址

这是我的代码

import bluetooth
import MySQLdb

nearby_devices = bluetooth.discover_devices()
db = MySQLdb.connect(host,user,passwd,db)
cursor = db.cursor()

for addr in nearby_devices:
    cursor.execute("insert into user (macaddress) values (%s)" % addr)
    print ("%s" % (addr))
db.commit()

1 个答案:

答案 0 :(得分:1)

变化

false

  <body>
    <button>click</button>
   <script>
     navigator.mediaDevices.getUserMedia({audio:true})
     .then(stream => {
       const track =  stream.getAudioTracks()[0];
       console.log(track, track.readyState, stream, stream.active);
       track.onended = e => {
         console.log(e.type, track.readyState)
       }
       stream.oninactive = e => {
         console.log(e.type, stream.active)
       }
       document.querySelector("button").onclick = () => {
         track.stop();
         stream.removeTrack(track);
       }
     })
   </script>
  </body>

试一试!