python - PYODBC to upload a file in a database from a webpage -


how create webpage can upload file , connected pyodbc upload directly database? below code path of file hard coded want make dynamic creating simple web page has option upload file , file should uploaded database using python odbc connection:

import pyodbc conn = pyodbc.connect('driver={hdbodbc};servernode=xxyyy;serverdb=xxx;uid=xyxyxyx;pwd=xxxxx') cur = conn.cursor() **file = open('c:/pdf-sample.pdf','rb')** //this hard coded path of file, should changed , taken dynamically web page file uploaded. content = file.read() cur.execute("insert test.my_table_blob_test values(?,?)", ('1',content)) cur.execute("commit") file.close() cur.close() conn.close() 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -