Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: How to specify a field name dynamically

Reply
Thread Tools

Re: How to specify a field name dynamically

 
 
Dave Angel
Guest
Posts: n/a
 
      11-07-2012
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
1.Enter space bar for field names and save the field.The field shoud not get saved and an alert should be there as"Space bars are not allowed" Sound Javascript 2 09-28-2006 02:43 PM
Read form "name" attribute when it contains form field with name "name" Pavils Jurjans Javascript 3 03-18-2005 01:39 PM
Request.Form("Field Name") Versus Request.QueryString("Field Name") John Davis ASP General 2 08-18-2003 05:00 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57