Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'subject:password': 0.05; 'subject:Python': 0.06; 'cursor': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"test"': 0.16; "'host':": 0.16; 'igor': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'all,': 0.19; 'connects': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'script': 0.25; 'this:': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'host': 0.29; 'dec': 0.30; '"",': 0.31; 'but': 0.35; 'there': 0.35; 'hi,': 0.36; 'skip:m 40': 0.38; 'from:charset:utf-8': 0.61; 'content-disposition:inline': 0.62; 'to:addr:gmail.com': 0.65; 'received:86': 0.91; 'received:hu': 0.93; '2013': 0.98 X-Spam-Flag: NO X-Spam-Score: -1.91 X-Spam-Level: X-Spam-Status: No, score=-1.91 tagged_above=-20 required=4 tests=[ALL_TRUSTED=-1, AWL=0.088, BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=0.9] autolearn=no Date: Mon, 16 Dec 2013 12:16:41 +0100 From: Ervin =?utf-8?Q?Heged=C3=BCs?= To: Igor Korot Subject: Re: Python, mySQL and password References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387192608 news.xs4all.nl 2843 [2001:888:2000:d::a6]:45429 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62042 Hello, On Mon, Dec 16, 2013 at 02:55:29AM -0800, Igor Korot wrote: > Hi, ALL, > Is there a way to make python script that connects to mySQL DB ask for > a password on the: > > conn = mdb.connect(host, user) > > line. > The host variable is "localhost" and the user variable is "root" (for > developmental purposes). may be you think some like this: import MySQLdb dsn = { 'host': "127.0.0.1", 'user': "root", 'passwd': "", 'port': 3306, 'db': "test" } dsn['passwd'] = raw_input("Enter password for %s: " % (dsn['user'])) mysql = MySQLdb.connect(**dsn) cursor = mysql.cursor(MySQLdb.cursors.DictCursor) but at this way the password what you type will showing! a.