May-08-2019, 05:06 PM
If you are connecting to SQL Server then you have to use pyodbc
Since you are using mysql, it should be taking its own localhost name
If you using sql server, it should be taking its own localhost name as it fetches string info from drivers.
import pyodbc server = 'server_name' db = 'database_name' UID = 'user_id' conn = pyodbc.connect('DRIVER={SQL Server};SERVER=' + server + ';DATABASE=' + db + '; UID = ' + UID + '; PWD = ' + UID + 'Trusted_Connection=yes')or simply
import pyodbc conn = pyodbc.connect('Trusted_Connection=yes', driver = '{ODBC Driver 13 for SQL Server}',server = 'ServerName', database = 'DBname')Localhost is generic hostname-----> go to run---> cmd ---> hostname ... it will display
Since you are using mysql, it should be taking its own localhost name
If you using sql server, it should be taking its own localhost name as it fetches string info from drivers.