I made a script in my Django called "bdd.py" inside "polls" as you can see in this tree :

My problem is that this script is supposed to send some datas into my table torrent_infos in my MySQL database "TORRENTS" but i don't see anything in my table. Indeed when i execute the script it seems working:
root@debian:/home/florian/Documents/mysite/polls# python bdd.py
But my table still empty and i don't understand why. Have a look at my database:
mysql> DESCRIBE torrent_infos;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| Name | varchar(50) | YES | | NULL | |
| Size | varchar(50) | YES | | NULL | |
| Hash | varchar(60) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> SELECT * FROM torrent_infos ;
Empty set (0.01 sec)
And this is my script, probably the roots of the problem as you can see i take informations from the .torrent files in a folder and i'm trying to send it into my table torrent_infos. I tried some changes in the indentation without success. Any idea in mind are welcomed :
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import mysql.connector
import bencode
import binascii
import hashlib
import os
import sys
conn = mysql.connector.connect(host="localhost",user="root",password="root", database="TORRENTS")
cursor = conn.cursor()
path = "/home/florian/TorrentFiles"
dirs = os.listdir(path)
for file in dirs:
try:
with open(os.path.join(path, file), 'rb') as torrentfile:
torrent = bencode.bdecode(torrentfile.read())
user = ("torrent['info']['name']","torrent['info']['length']","(hashlib.sha1(bencode.bencode(torrent['info'])).hexdigest())")
cursor.execute("""INSERT INTO torrent_infos (Name, Size, Hash) VALUES(%s, %s, %s)""", user)
except bencode.BTL.BTFailure:
continue
conn.close()