Python Forum
How to pass encrypted pass to pyodbc script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to pass encrypted pass to pyodbc script
#1
Greetings to you all!
I'm trying to pull out some data from MS SQL DB.
I have to encrypt the user name and the pass, I found how to encrypt a text file and how to access my MS SQL DB but I have no idea how to put these two scripts together Sad .
Here is the encryption snippet:
#   Making the encryption key:

from cryptography.fernet import Fernet
key = Fernet.generate_key() 
print(key) # 

#   Incrypting the Password file

from cryptography.fernet import Fernet
key = b'5YBR7_2gufXlbmMg13QB9c71WR6h9m2Sq49tLwCsOVk='
cipher_suite = Fernet(key)
ciphered_text = cipher_suite.encrypt(b'Mypassword')
with open('C:/01/Python _passwords/encripted_bytes.bin', 'wb') as file_object:  file_object.write(ciphered_text)
And the DB access snipped:
import pyodbc 

conn = pyodbc.connect('DRIVER={SQL Server};SERVER=myremoteServer5.hps.com,1333;DATABASE=MYMSSQLDB;UID=aa;PWD=allgetlost')
cursor = conn.cursor()
for row in cursor.tables():
    print(row.table_name)
Any help is really appreciated.
Thank you
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pass arguments from bat file to pyhon script from application absolut 2 925 Jan-13-2025, 11:05 AM
Last Post: DeaD_EyE
  Get an FFMpeg pass to subprocess.PIPE to treat list as text file? haihal 2 987 Nov-21-2024, 11:48 PM
Last Post: haihal
  how to pass a mongdb command to a module and execute it. cspower 0 841 Feb-03-2024, 09:54 PM
Last Post: cspower
  Using pyodbc&pandas to load a Table data to df tester_V 3 2,703 Sep-09-2023, 08:55 PM
Last Post: tester_V
  How to pass -Xutf8 parametri to python tierox 2 1,719 Jun-07-2023, 07:17 AM
Last Post: tierox
  Pass variable to subprocess paulo79 4 12,671 Apr-12-2022, 12:35 PM
Last Post: DeaD_EyE
  pyodbc gmerritt 8 4,847 Feb-21-2022, 07:21 PM
Last Post: gmerritt
  How to pass variables from one class to another hobbyist 18 19,680 Oct-01-2021, 05:54 PM
Last Post: deanhystad
Question How to pass a method as argument in an another method? anilanvesh 6 3,997 Sep-30-2021, 10:18 PM
Last Post: deanhystad
  How to pass list of values to a API request URL chetansaip99 0 4,311 Sep-28-2021, 07:37 AM
Last Post: chetansaip99

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020