I've tried adding a commit() after an update, but still the same
thing.
Here's the model for parts:
#################
try:
db = SQLDB("postgres://user:passw...@localhost:5432/table")
except:
db = SQLDB("sqlite://service.db")
PART_TYPES = [ 'Cooling', 'Heating', 'Refrigeration', 'Misc']
db.define_table('part',
SQLField('part_Number', notnull=True),
SQLField('part_Description'),
SQLField('part_Type', requires=IS_IN_SET(PART_TYPES)),
SQLField('warehouse_stock', 'double'),
SQLField('warehouse_oh', 'double'),
SQLField('service_van', 'double'),
SQLField('service_van_oh', 'double'),
SQLField('on_order', 'double'),
SQLField('list', 'double'),
SQLField('margin', 'double'),
)
#############
Here are the important parts of the controller:
def index():
allParts = db().select(db.part.ALL)
records = SQLTABLE(allParts, truncate=100, _id="partList")
return dict(records=records)
def update():
recordId = request.vars.id
updatedField = request.vars.updatedField
updatedData = request.vars.updatedData
row = (db.part.id == recordId)
elif updatedField == 'part_Description':
db.part[recordId].update_record(part_Description = updatedData)
db.commit()
return "good"
###############
On an unrelated note, I don't understand how I can use update_record
(updatedField = updatedData). DenesL said I can use dictionaries but
I'm pretty sure I'm not using them right by doing update_record(dict
(updatedField = updatedData)).
Thanks for your help.
On May 3, 12:01 am, mdipierro <[email protected]> wrote:
> I am very puzzled by this. I have never seen it before.
>
> Can you send me the model, the controller that does update and the
> controller that does select?
>
> Can you get the postgresql database to log all SQL requests and send
> me the log?
>
> Can you also try adding a db.commit() after the update to see it
> changes anything?
>
> Massimo
>
> On May 2, 11:35 pm, Brian <[email protected]> wrote:
>
> > Sorry Massimo if I was unclear.
>
> > When I develop locally, I'm using SQLite. When I push my code to my
> > remote server, it's using postgres (I'm using try: postgres & except:
> > sqlite).
>
> > So locally(sqlite), my code works great. I can update records and
> > everything is smooth.
> > When I push my code to the server (postgres) thats when I get my
> > issues stated above. Just to make sure it wasn't something funny on
> > the server, I forced it to use SQLite and it worked fine.
>
> > On May 2, 4:59 pm, mdipierro <[email protected]> wrote:
>
> > > Brian. I am confused. didn't you say the problem was with SQLite? What
> > > does "swicthed to SQLite and it worked" means?
>
> > > May I guess you are running Leopard? I know SQLite that ships with
> > > Leopard has some issues.
>
> > > If my assumption is correct, can you try the mac binary instead?
>
> > > massimo
>
> > > On May 2, 1:24 pm, Brian <[email protected]> wrote:
>
> > > > I can switch to SQLite and it works perfect with or without the
> > > > db.commit().
>
> > > > On May 2, 1:06 pm, Brian <[email protected]> wrote:
>
> > > > > Thanks for the response.
>
> > > > > I added a commit() after my update_record but I'm still having the
> > > > > same issue.
>
> > > > > Using the DB admin, I edited a record on there and the same thing
> > > > > happens: modify a record and it doesn't show up on a "db.part.id>0" in
> > > > > the admin interface. I can view and modify it if I go to a specific
> > > > > record, but can't view them all.
>
> > > > > Is this something with postgres? Did I set something up wrong?
>
> > > > > On May 2, 11:33 am, DenesL <[email protected]> wrote:
>
> > > > > > Oops, more answers follow:
>
> > > > > > On May 2, 8:23 am, Brian <[email protected]> wrote:
>
> > > > > > > 2) What's the difference between an update and an update_record?
>
> > > > > > update works on a set of records:
> > > > > > db(db.person.id>3).update(name='Ken')
>
> > > > > > update_record is for a single record:
> > > > > > rows=db(db.person.id>2).select()
> > > > > > row=rows[0]
> > > > > > row.update_record(name='Curt')
>
> > > > > > > 3) With the above example, is there anyway I can use a variable
> > > > > > > for a
> > > > > > > field name? So instead of having a bunch of if's and elif's to go
> > > > > > > through the field, I could do a:
> > > > > > > db(row).update(updatedField = updatedData)
>
> > > > > > The parameters are passed as a dictionary so you could create one.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---