Python with Mysql - pdf file insertion during runtime
Question: I have a script that stores results in pdf format in a particular folder. I
want to create a mysql database ( which is successful with the below code ),
and populate the pdf results to it. what would be the best way , storing the
file as such , or as reference to the location. The file size would be around
2MB. Could someone help in explaining the same with some working examples. I
am new to both python and mysql.Thanks in advance. To clarify more : I tried
using LOAD DATA INFILE and the BLOB type for the result file column , but it
dosent seem to work .I am using pymysql api module to connect to the
database.Below code is to connect to the database and is successful.

    
    
    import pymsql
    conn = pymysql.connect(host='hostname', port=3306, user='root', passwd='abcdef', db='mydb')
    cur = conn.cursor()
    cur.execute("SELECT * FROM userlogin")
    for r in cur.fetchall():
       print(r)
    cur.close()
    conn.close()
    


Answer: Since you seem to be close to getting mysql to store strings for you (user
names), your best bet is to just stick with what you did there and store the
file path just as you stored the strings in your `userlogin` table (but in a
different table with a foreign key to `userlogin`). It will probably be the
most efficient approach in the long run anyway, especially if you store
important metadata along with the file path (like keywords or even complete
n-gram sets)... now you're talking about a file indexing system like Google
Desktop or Xapian... just so you know what you're up against if you want to do
this the "best" way.

