python - TypeError: 'NoneType' object is not subscriptable "channel_id = c.fetchone()[0]" -


i getting above on following code

def del_owner(p, i): if i.host == p.config.owner_host:     channel = i.sender     hostname = i.group(2)      conn = sqlite3.connect("aamnews.db")     c = conn.cursor()      # channel's id     c.execute("select id channels name=?", (channel,))     channel_id = c.fetchone()[0]      # chanel's owners     c.execute("select owners.hostname owners inner join channel_owners on owners.id=channel_owners.owner_id channel_id=?", (channel_id,))     owners = [p.config.owner_host] + [e[0] e in c.fetchall()]      if hostname in owners:         # owner_id         c.execute("select id owners hostname=?", (hostname,))         owner_id = c.fetchone()[0]          c.execute("delete channel_owners owner_id=? , channel_id=?", (owner_id, channel_id))          # check if owner has other channels         c.execute("select channel_id channel_owners owner_id=?", (owner_id,))         result = c.fetchone()          if not result:             c.execute("delete owners id=?", (owner_id,))          conn.commit()         conn.close()          return p.say("deleted owner.")      else:         conn.close()         return p.say("owner doesn't exist.") else:     return p.say("command global owner only.") 

it complains on line has ==> channel_id = c.fetchone()[0]

i'm not sure how handle , appreciated


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -