Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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; 'python,': 0.02; 'exception': 0.03; 'syntax': 0.03; 'subject:How': 0.09; 'argument,': 0.09; 'bug': 0.10; 'cc:addr:python-list': 0.10; 'def': 0.10; 'assume': 0.11; 'library': 0.15; 'crashes': 0.16; 'exception?': 0.16; 'slashes': 0.16; 'statements,': 0.16; 'traceback.': 0.16; 'using,': 0.16; 'wrote:': 0.17; 'specify': 0.17; 'causing': 0.20; 'define': 0.20; 'import': 0.21; 'libraries': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'class.': 0.23; 'insert': 0.23; 'somebody': 0.23; 'installed': 0.23; 'cc:no real name:2**0': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'guess': 0.27; 'errors.': 0.27; 'in.': 0.27; 'arguments.': 0.29; 'indentation': 0.29; 'case,': 0.29; 'maybe': 0.29; 'field,': 0.30; 'version,': 0.30; 'function': 0.30; 'getting': 0.33; 'stands': 0.33; 'self': 0.34; 'wrong': 0.34; 'so,': 0.35; 'pm,': 0.35; 'really': 0.36; 'but': 0.36; "i'll": 0.36; 'does': 0.37; 'uses': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'first': 0.61; 'chance': 0.61; 'show': 0.63; 'charset:windows-1252': 0.65; 'therefore': 0.65; 'header:Reply-To:1': 0.68; 'records': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72 Date: Tue, 06 Nov 2012 22:36:18 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: jack Subject: Re: How to specify a field name dynamically References: In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:0YbdNUmGmirQsLOWNR0Odsf598NwErJ1I2BaBbi5EwK EAV1pHQGg4Jn2N3cjcjscLZN2PHWv7g3bHokN26TV/ROS+Tm+P V+H69Ma6PVujkiJC0PxRRQbv7XzdLlU7Vq+xsNshWKEGc/ddRM i4J22Lp+p0So8WQeGprU3qgS5ejbLXYIAby//exFGj2xa6zFDY Ev9sKrU2pLYWbC8zbCeJk2quMXgrf2hpr/WTNcJME2iUw+GEyD eo7G+iNQ0SuvGQ2PQEnKUZ8rfMIC7vgvnv+tQpF9xH+W1Z7KKq yv7wwB2qA3l99VnSOR6tJgiA8OOosfhG1V3PZx92SU/idIx3g= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352259408 news.xs4all.nl 6876 [2001:888:2000:d::a6]:59445 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32862 On 11/06/2012 10:14 PM, jack wrote: > I have three tables: What's a table? I'll assume you're using Python, but what version, and what extra libraries do you have installed ? At least show your import statements, so we might have a chance at guessing. I'll assume the db stands for database, but what database, or what library??? if it really is a database question, and you specify what library you're using, then maybe somebody who uses that will jump in. > table1 > |覧覧覧慾 > | id | f1 | > |覧覧覧慾 > > table2 > |覧覧覧慾 > | id | f2 | > |覧覧覧慾 > > table3 > |覧覧覧慾 > | id | f3 | > |覧覧覧慾 > > > I want define a function to insert records to someone,but I don't know > how to specify a field name dynamically. > I had a try like this > > / def insert_record(table, field, goods):// > // return db.insert(table, field=goods//)/ > or > / def insert_record(table, **kv):// > // return db.insert(table, **kv)/ > > but it does not works > That's not much of a clue. Do you mean you get an exception? If so, paste it into a message, the full traceback. Or you mean it returns the wrong data? Or it crashes your OS? My first guess would be that those slashes are causing syntax errors. But if that's a bug in your OS's copy/paste, then I'd say you have indentation problems. Or maybe these are not just functions, but methods inside a class. And in that case, I might guess that you're missing the self argument, and therefore getting an exception of wrong number of arguments. -- DaveA