Re: Valid SQL?



I have this string that I am sending via a Cursor.execute() using
MySQLdb:

insert into table Ping82_eb13__elearn__ihost__com (`dateTime`,
`values`) values(
"Fri May 12 11:39:02 2006", "1")

Does anyone see anything wrong with this SQL syntax?

While this is the *python* list, rather than a SQL list...

It looks like you're using two diff. styles of quoting. And using back-quotes at that. IIRC, ANSI-SQL (nebulous standard as it is, implemented to taste by each vendor) calls for using single-quotes as strings. Some RDBMS engines support the double-quote (MySQL does). None that I know of support the back-tick. Unless it's an RDBMS scheme for surrounding column or table-names that might have spaces in them (or might be SQL keywords). You might also want to make sure that your RDBMS doesn't have a column data-type of "datetime" (MySQL does) which might choke matters too...having a column-name that potentially clashes with the name of a datatype is just asking for trouble :)

Additionally, the syntax for INSERT INTO statements usually leaves the word TABLE as optional. I think this is the first time I've seen someone opt for it :) Most SQL I've seen just does

INSERT INTO tblFoo (field1, field2) VALUES ('value1', 'value2')

You don't include the DDL that defines the structure of the table into which you're shoving matters, so it's somewhat hard to tell what's going on. Are primary keys being violated? Are data-types awry?

Lastly, you don't include the text of the error message that you're getting back...most error messages try to be helpful, and in this case, it would certainly be helpful. :)

Just a few thoughts,

-tkc




.



Relevant Pages

  • Re: SQL to allow a "no preference (all) choice
    ... I don't know enough about SQL syntax. ... Here is the error message and ... Syntax error (missing ...
    (microsoft.public.inetserver.asp.db)
  • OT SQL
    ... I am trying to set up my MySQL Database on an older version than it is ... I dumped my SQL and it is... ... but when i try and run this sql in PHPMyAdmin I get the error message ... #1064 - You have an error in your SQL syntax. ...
    (alt.php)
  • Re: Moderately OT: Scientific File Design
    ... From the extensive description of your data organization, it appears that this is the kind of problem that is well-suited to an RDBMS. ... All modern RDBMS packages use Structured Query Language (SQL) as an interface language to the RDBMS. ... Oracle/Rdb is very well tailored to the OpenVMS operating system and, IMHO, easier to use than the regular Oracle product. ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: Moderately OT: Scientific File Design
    ... signals, and so on. ... From the extensive description of your data organization, it appears that this is the kind of problem that is well-suited to an RDBMS. ... All modern RDBMS packages use Structured Query Language (SQL) as an interface language to the RDBMS. ... Oracle/Rdb is very well tailored to the OpenVMS operating system and, IMHO, easier to use than the regular Oracle product. ...
    (comp.lang.fortran)
  • SSIS not converting between non-unicode and unicode
    ... I don't know about you, but adding data conversion objects, and selecting each field... ... asking for a fix to automatically convert non-unicode to unicode in 2005!!! ... I am converting a simple (at least in the SQL Server 2000 DTS days) to this ... error message stays the same ...
    (microsoft.public.sqlserver.dts)