Oh never mind - I forgot the commit!! On Feb 26, 2:39 pm, Stodge <[email protected]> wrote: > Same problem from the console - no new record: > python > Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57) > [GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> > from trac.env import open_environment > > >>> env = open_environment("/srv/trac/test") > >>> query = "INSERT INTO codereviews (url, time, name, message, rid) values > >>> ('url', '752125', 'mike', 'Log message', '31')" > >>> db = env.get_db_cnx() > >>> cursor = db.cursor() > >>> cursor.execute(query) > >>> query > > "INSERT INTO codereviews (url, time, name, message, rid) values > ('url', '752125', 'mike', 'Log message', '31')" > > > > On Feb 26, 2:34 pm, Stodge <[email protected]> wrote: > > > The SQL query is: > > > INSERT INTO codereviews (url, time, name, message, rid) values ('url', > > '752125', 'mike', 'Log message', '31') > > > The PostgreSQL table is: > > > CREATE TABLE codereviews > > ( > > url text, > > id serial NOT NULL, > > "time" integer, > > "name" text, > > message text, > > rid integer, > > CONSTRAINT codereviews_pkey PRIMARY KEY (id) > > ) > > > On Feb 26, 2:31 pm, Stodge <[email protected]> wrote: > > > > I'm trying to load a Trac environment from a subversion plugin > > > (python) and insert a record into its database. The query completes > > > successfully but no new records are created. There are no errors in > > > any log, including Apache, PostgreSQL or Trac. Any ideas why query > > > isn't creating a new record? Thanks > > > > The code is: > > > > env = open_environment("/srv/trac/test") > > > > # Create the entry in the Trac environment. > > > # Generate the query. > > > query = "INSERT INTO codereviews (url, time, name, message, rid) > > > values ('%s', '%s', '%s', '%s', '%s')" % \ > > > ('url', > > > > > > str(datetime.datetime.now(utc).microsecond), > > > author, > > > 'Log message', > > > review_id) > > > > syslog.syslog("Query = <%s>" % query) > > > > # Perform the DB operation. > > > try: > > > db = env.get_db_cnx() > > > cursor = db.cursor() > > > > # Perform the insert. > > > cursor.execute(query) > > > > syslog.syslog("Review request added to Trac") > >
-- You received this message because you are subscribed to the Google Groups "Trac Users" 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/trac-users?hl=en.
