Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.070 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'subject:string': 0.09; 'cc:addr:python-list': 0.11; "';'": 0.16; '(assuming': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'thanks.': 0.20; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'skip:p 30': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'work.': 0.31; "skip:' 10": 0.31; 'larry': 0.31; 'anyone': 0.31; 'probably': 0.32; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'pm,': 0.38; 'does': 0.39; 'skip:p 20': 0.39; 'is.': 0.60; 'solve': 0.60; 'tell': 0.60; "you're": 0.61; '30,': 0.65; 'to:addr:gmail.com': 0.65; 'not:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2/04HlL+y8BU9O9DdCqmO/hy2LhoXP6N/S4lP0t+M9o=; b=CGU1OfEMzpS1+aAtLZwQ3BF7tBjwvIgIyScYebiVhDa2DgwH6qk+eeBk8vgg3H3piB x7acTf9NFG/2SggoDc2u3GYpQgJAudFrC1Q8nm5K+YVVQVZoJn0QouGNeehuZbPIyWxk bB+x9QgHaNSZN7JBy7IJauVM5gywwhRSA3O/xCUVOYRbNofIzGGS8F4mJFcWVL1v0l2F bHTeNBInHFjzK2bfzTYuisRcDjH+cwUHjI6Y6VLvzna2vRu9JLQZPrYwQ3zcUNcOe7Ic rLS9JMYHuwdKFtyEpq0X3EC2Tww8lzKCS/BReR6ArG417oDyfJszre6/dNdwxh0sc/VP p3mw== MIME-Version: 1.0 X-Received: by 10.180.89.1 with SMTP id bk1mr883142wib.35.1398820518077; Tue, 29 Apr 2014 18:15:18 -0700 (PDT) In-Reply-To: References: Date: Tue, 29 Apr 2014 19:15:18 -0600 Subject: Re: pyodbc connect string From: Larry Martell To: Chris Angelico Content-Type: text/plain; charset=UTF-8 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398820519 news.xs4all.nl 2909 [2001:888:2000:d::a6]:57055 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70753 On Tue, Apr 29, 2014 at 7:09 PM, Chris Angelico wrote: > On Wed, Apr 30, 2014 at 10:57 AM, Larry Martell wrote: >> This works: >> >> pyodbc.connect('DRIVER=FreeTDS;' 'SERVER=xx.xx.xx.xx;' 'PORT=1433;' >> 'DATABASE=blah;' 'UID=foo;' 'PWD=bar;') >> >> But this does not: >> >> pyodbc.connect(conn_str) >> >> conn_str is constructed with: >> >> conn_str = "'DRIVER=%s;' 'SERVER=%s;' 'PORT=%s;' 'DATABASE=%s;' >> 'UID=%s;' 'PWD=%s;'" \ >> % (RECIPE_DB['DRIVER'], RECIPE_DB['SERVER'], >> RECIPE_DB['PORT'], RECIPE_DB['DATABASE'], >> RECIPE_DB['USER'], RECIPE_DB['PASSWORD']) >> >> Anyone have any ideas as to why this doesn't work. > > Start by printing out conn_str. That'll tell you if it's actually > coming out the way you think it is. I can see where the problem > probably is (assuming these are faithful copy/pastes), in the form of > an extra double quote; but actually print them out and see what you're > getting. When I print conn_str out it does not have the double quotes, But I was able to solve this by doing this: pyodbc.connect('DRIVER=' + RECIPE_DB['DRIVER'] + ';' + 'SERVER=' + RECIPE_DB['SERVER'] + ';' + 'PORT=' + RECIPE_DB['PORT'] + ';' + 'DATABASE=' + RECIPE_DB['DATABASE'] + ';' + 'UID=' + RECIPE_DB['USER'] + ';' + 'PWD=' + RECIPE_DB['PASSWORD'] + ';') ' Thanks.