Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.05; 'insert': 0.05; 'mysql,': 0.07; '"class"': 0.09; '__init__': 0.09; 'arguments,': 0.09; 'classes.': 0.09; 'function,': 0.09; 'instance.': 0.09; 'logic': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'returns,': 0.09; 'statements': 0.09; 'testing,': 0.09; 'throws': 0.09; 'gui': 0.12; 'jan': 0.12; '407': 0.16; '415': 0.16; '>the': 0.16; 'dump': 0.16; 'message- id:@4ax.com': 0.16; 'personally,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'script,': 0.16; 'str()': 0.16; 'things...': 0.16; 'exception': 0.16; 'language': 0.16; 'file,': 0.19; 'passing': 0.19; 'thu,': 0.19; 'fit': 0.20; 'seems': 0.21; 'issue.': 0.22; 'instance,': 0.24; "shouldn't": 0.24; 'url:home': 0.24; 'sort': 0.25; 'tables': 0.26; 'header:X -Complaints-To:1': 0.27; 'function': 0.29; 'designer': 0.30; 'code': 0.31; 'lines': 0.31; 'invoke': 0.31; 'operations.': 0.31; 'raised': 0.31; 'requesting': 0.31; 'file': 0.32; 'class': 0.32; 'actual': 0.34; 'table': 0.34; 'maybe': 0.34; "i'd": 0.34; 'could': 0.34; 'connection': 0.35; 'something': 0.35; 'definition': 0.35; 'operations': 0.35; 'there': 0.35; '+0200,': 0.36; 'adjust': 0.36; 'belong': 0.36; 'done,': 0.36; 'skip:> 10': 0.36; 'skip:j 20': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'detail': 0.37; 'too': 0.37; 'requirements': 0.37; 'two': 0.37; 'list': 0.37; 'received:76': 0.38; 'process,': 0.38; 'to:addr :python-list': 0.38; 'files': 0.38; 'issue': 0.38; 'does': 0.39; 'launch': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'even': 0.60; 'serving': 0.60; 'most': 0.60; 'full': 0.61; 'entire': 0.61; 'first': 0.61; 'save': 0.62; 'name': 0.63; 'such': 0.63; 'soon': 0.63; 'within': 0.65; 'close': 0.67; 'bothered': 0.68; 'study': 0.69; 'obvious': 0.74; '2015': 0.84; 'effectively,': 0.84; 'initiates': 0.84; 'interrupt': 0.84; 'jet': 0.84; 'thing,': 0.91; 'connection,': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: MySQL connections Date: Thu, 15 Jan 2015 20:18:09 -0500 Organization: IISS Elusive Unicorn References: <5F6F0C3BBA694C15A513F94735D89E18@JakesPC> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-24-142.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421371093 news.xs4all.nl 2902 [2001:888:2000:d::a6]:54977 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83844 On Thu, 15 Jan 2015 18:40:31 +0200, "Jacob Kruger" declaimed the following: >If you want to check it out, have attached the full code file - might be a >bit messy/large - but, effectively, right at bottom, launch an instance of >the class a2m, passing through arguments, and then from within __init__ call >convertProcess function, which then initiates process, harvesting sort of >rendition/version of structure out of MS access database file, makes call to >convertSQL to generate structural SQL script, and save it to a file, which >then calls convertData function to generate insert statements to populate >database, and then that makes a call to convertExport, if you passed a >command line argument in requesting mysql, and that's the current issue >function - have stripped most of actual functionality out of it, since am >just testing, so the first 16 lines of that function are what's relevant at >moment - think shouldn't rely on any other self. objects/attributes as such >either, unless step-through process is an issue. > I don't intend to study this in much detail but... At line 407 you CLOSE the connection to the DBMS. At line 414 you invoke sys.exit() -- which means everything from line 415 to 437 is meaningless, and 438-446 will only be invoked if an exception is caught, which could only be raised in 394-405, and 413-414. I have to ask why you even bothered with a "class" -- about the only purpose that class seems to be serving is to contain the connection information... There's no obvious state change in the instance -- each method seems to be a self-contained function. Your main never keeps an instance of "a2m", a2m(s_mdb, s_mdb_pass, s_target, s_target_value) will create an instance, and as soon as it returns, throws away the instance. The __init__ calls convertProcess() which calls convertSQL() which calls convertData() which calls convertExport()... etc. There is no modularization, no place to interrupt things... You use way too many str() calls -- sys.argv is already a list of strings... Personally, I'd dump the entire thing, get a good set of requirements for what needs to be done, and then maybe create TWO classes... One class to encapsulate the JET database operations (JET is the proper name of M$ RDBM using MDB files -- Access is just a GUI report writer/form designer that uses JET), the other class to encapsulate MySQL operations. The manipulations to adjust fields from one engine to the other does not belong in either of the engine specific classes. The main logic may be something like: jet = JET(connection, information) mysql = MySQL(its, connection, information) tables = jet.getTableList() for table in tables: tdef = jet.getTableDef(table) #manipulate JET table definition to make fit MySQL language mysql.createTableDef(table, manipulated_tdef) tdata = jet.getTableData(table) for rec in tdata: #adjust fields to fit MySQL types mysql.insertRec(table, adjusted_rec) etc. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/