pyodbc DSN question

Discussion in 'Programmer's Corner' started by mbxs3, Sep 21, 2016.

  1. mbxs3

    Thread Starter Active Member

    Oct 14, 2009
    141
    3
    I have a working python script that I compile into an exe with pyinstaller.

    The script makes a database connection and in my dev setup, I am passing the database connection parameters (username, password) in the connection string.

    The exe will end up running on another users PC and, while I think it unlikely, I do not want them to have the ability to extract the database password from any of my code.

    I was hoping to create a DSN in the Windows ODBC Data Source Administrator on the production PC and only pass the DSN parameter in my python code. However, I have been unsuccessful in getting this to work. In my searching, all the example I see using a DSN also have a password assigned in the pyodb connection string. So is what I want to do even possible?
     
  2. upand_at_them

    Active Member

    May 15, 2010
    246
    29
  3. mbxs3

    Thread Starter Active Member

    Oct 14, 2009
    141
    3
    This is actually the same webpage I followed to setup my original connection. However, when I use a string like the one you show, my connection is not successful.

    I have the ODBC configured on the Windows machine in the ODBC Administrator. (I am using a 64-bit machine and I configured the connection in the 64-bit and 32-bit ODBC administrator, I am pretty sure the 32-bit version is called).

    May be a dumb question but MyDSN should be whatever I named the data source on the ODBC administrator, correct?
     
  4. upand_at_them

    Active Member

    May 15, 2010
    246
    29
    Yes, "MyDSN" should be the name of your data source.

    Try:
     
Loading...