Modify

Opened 17 years ago

Closed 12 years ago

#1505 closed defect (fixed)

insert into session sql syntax error

Reported by: brian@… Owned by: Anton Stroganov
Priority: normal Component: MantisImportScript
Severity: critical Keywords: insert, session, sql, syntax, python, long quote
Cc: Trac Release: 0.10

Description

I was getting error message about incorrect syntax for the "INSERT INTO session" statements.

I changed this

                       c.execute(
                       """INSERT INTO session
                           (sid, authenticated, last_visit)
                       VALUES """,(result[0]['username'].encode('utf-8'), '1', result[0]['last_visit'].strftime('%s')))

to this

                       c.execute( "INSERT INTO session (sid, authenticated, last_visit) VALUES ('%s', %s, %s)" % (result[0]['username'].encode('utf-8'), '1', result[0]['last_visit'].strftime('%s')) )

and it worked.

I don't know the term for these python long quotes, so please retag this ticket appropriately.

Oh it just dawned on me. You can probably keep the params version of the execute(), but you need to mark the parameters in the query with question marks, or $1, $2, or $3, or something. Shrug, i dunno, it's my first day speaking python.

Attachments (0)

Change History (2)

comment:1 Changed 16 years ago by simona@…

Try to spam my mail plz.

comment:2 Changed 12 years ago by Anton Stroganov

Resolution: fixed
Status: newclosed

thank you

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Anton Stroganov.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.