Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

upload file to SQL server pyodbc python

# Get connection
connection = pyodbc.connect(...)
filename = 'MyFile.pdf'
insert = 'insert into FileTable (name, document) values (?,?)'

# open file as binary and read into a variable
with open(filename, 'rb') as f:
    bindata = f.read()

# build query
binparams = ('MyFile.pdf', pyodbc.Binary(bindata))

# insert binary
connection.cursor().execute(insert, binparams)
connection.commit()
connection.close()
Comment

PREVIOUS NEXT
Code Example
Python :: dividing col in csv 
Python :: create horizontal descriptives table pandas 
Python :: the requested url was not found on the server. flask 
Python :: how to increase width of line in graph of linear regression in matplotlib 
Python :: to compare a part of a string to string 
Python :: extract metadata from xml tei file python 
Python :: matrix of matrices python grepper 
Python :: crank nicholson scheme python 
Python :: cv2 pink color range 
Python :: examples of function decorators in Python 
Python :: nn.softmax for pure sconvoultional classifier 
Python :: hwoto neglect if any exception happening in python 
Python :: string to date in BQ 
Python :: python iterar claves 
Python :: bashrc rc meaning 
Python :: list of letter in word python 
Python :: aggregation with f() in django rest api 
Python :: remove all the valu ein dict exacpt provided key pythn 
Python :: add fully connected layers at encoder of autoencoder 
Python :: requests-html 
Python :: Reduces the elements of this RDD using the specified commutative and associative binary operator 
Python :: open chrome with python stack overflow 
Python :: true false array to black and white 
Python :: python sort isdigit 
Python :: IS Dashie a name 
Python :: print python setencode 
Python :: can the function inside a function be global if the function before it is global 
Python :: gym notebook render env 
Python :: a = [ int(i) for i in range(100, 104)] list python 
Python :: if self.quitting: raise BdbQuit in classbased view 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =