问题描述:

I'm newbie in Python (2.7).

I'm using pypyodbc for a connection with sql server. It's works, but, I have a connection string in plain text.

How could I add security to my connection String?

My code:

import pypyodbc

import datetime

class connection:

db_host = ''

db_name = ''

db_user = ''

db_password = ''

def __init__(self):

try:

connectionString = 'Driver={SQL Server};Server=' + self.db_host + ';Database=' + self.db_name + ';Trusted_Connection=Yes;UID=' + self.db_user + ';PWD=' + self.db_password + ';'

self.conexion = pypyodbc.connect(connectionString)

except:

print("No se puede conectar a la base de datos.")

is plain text.

I think that I must to have in mind the compile file or SQL Server's users.

But, for example, in c# I can create static files with variables or use app config with this.

相关阅读:
Top