Solved

permission denied on serial

Posted on 2007-03-23
3
1,184 Views
Last Modified: 2008-01-09
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
Comment
Question by:astar666
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
earth man2 earned 500 total points
Comment Utility
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
 
LVL 22

Expert Comment

by:earth man2
Comment Utility
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
 

Author Comment

by:astar666
Comment Utility
took grant all to work
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now