• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1194
  • Last Modified:

permission denied on serial

while doing an insert in postgresql, I get permission denied on a serial field.  Here is the error:

 /home/familynetwork/cgi-bin/addideas.py
  180 for category in fields["category"]:
  181         cursor.execute("""insert into ideacategories (name,category) values (%s,%s)""",
  182                 (sqlinjection(fields["name"][0]),
  183                 sqlinjection(category)))
  184          
sqlinjection = <function sqlinjection>, fields = {'URL': [''], 'category': ['Advocacy', 'Animals'], 'city': [''], 'contactperson': [''], 'cost': [''], 'country': ['United States'], 'county': [''], 'description': [''], 'differently': [''], 'email': [''], ...}, category = 'Advocacy'

 /usr/lib/python2.3/site-packages/pgdb.py in execute(self=<pgdb.pgdbCursor instance>, operation='insert into ideacategories (name,category) values (%s,%s)', params=('test', 'Advocacy'))
  173                 else:
  174                         # not a list of tuples
  175                         self.executemany(operation, (params,))
  176
  177         def executemany(self, operation, param_seq):
self = <pgdb.pgdbCursor instance>, self.executemany = <bound method pgdbCursor.executemany of <pgdb.pgdbCursor instance>>, operation = 'insert into ideacategories (name,category) values (%s,%s)', params = ('test', 'Advocacy')

 /usr/lib/python2.3/site-packages/pgdb.py in executemany(self=<pgdb.pgdbCursor instance>, operation='insert into ideacategories (name,category) values (%s,%s)', param_seq=(('test', 'Advocacy'),))
  194                                         self.rowcount = -1
  195                 except Error, msg:
  196                         raise DatabaseError, "error '%s' in '%s'" % ( msg, sql )
  197                 except Exception, err:
  198                         raise OperationalError, "internal error in '%s': %s" % (sql,err)
global DatabaseError = <class pg.DatabaseError>, msg = <pg.ProgrammingError instance>, sql = "insert into ideacategories (name,category) values ('test','Advocacy')"

DatabaseError: error 'ERROR: permission denied for sequence ideacategories_categoryid_seq ' in 'insert into ideacategories (name,category) values ('test','Advocacy')'
      args = ("error 'ERROR: permission denied for sequence id...ories (name,category) values ('test','Advocacy')'",)

/home/familynetwork/logs/tracebacks/tmpIye7to.html contains the description of this error.


The table is:



create table ideacategories (
      categoryid      serial,
      name            varchar(100),
      category      varchar(100)
      ) with oids


some permissions:
CREATE USER addidea;
GRANT SELECT on banips to addidea;
GRANT INSERT on banips to addidea;
GRANT SELECT on accounts to addidea;
GRANT SELECT on ideas to addidea;
GRANT INSERT on ideas to addidea;
GRANT ALL on ideacategories to addidea;

How do I e get by the error.
0
astar666
Asked:
astar666
  • 2
1 Solution
 
earth man2Commented:
treacle=> create table ideacategories (
treacle(>       categoryid      serial,
treacle(>       name            varchar(100),
treacle(>       category      varchar(100)
treacle(>       ) with oids
treacle-> ;
NOTICE:  CREATE TABLE will create implicit sequence "ideacategories_categoryid_seq" for serial column "ideacategories.categoryid"
CREATE TABLE
treacle=>

therefore try
grant select on ideacategories_categoryid_seq to addidea;
0
 
earth man2Commented:
PS You probably should define table using primary key clause ie
create table ideacategories (
      categoryid      serial primary key,
      name            varchar(100),
      category      varchar(100)
      ) without oids;
0
 
astar666Author Commented:
took grant all to work
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now