Posts

Showing posts from August, 2022

Python DB connection MSSQL

 WE can by using any  one of the following drivers,  Python SQL driver - pyodbc Python SQL driver - pymssql Pip instal pymssql The  pymssql.connect  function is used to connect to SQL Database. Sql results will be displayed in tuples cursor.execute function Cursor objects are used to streamline the connection between the puthon and sql server, execute SQL statements This function accepts a query and returns a result set can be iterated over with the use of cursor.fetchone() pip install pyodbc import pyodbc # Some other example server values are # server = 'localhost\sqlexpress' # for a named instance # server = 'myserver,port' # to specify an alternate port server = '**********.database.windows.net' database = '********' username = '*******' password = '******@easapi$' cnxn = pyodbc.connect( 'DRIVER={SQL Server Native Client 11.0};SERVER=' +server+ ';DATABASE=' +database+ ';UID=' +username+ ';PWD=' + passwo...

Python File Upload using API Post

 Python File upload using API: urlpetshop = 'https://petstore.swagger.io/v2/pet/9843217/uploadImage' files = { 'file' : open ( 'C: \\ temp \\ sampleimage.jpg' , 'rb' )} imageuploadPost= requests.post(urlpetshop , files = files) print (imageuploadPost) print (imageuploadPost.text) print (imageuploadPost.status_code)