[Tutor] This should be easy

Alberto Troiano albertito_g at hotmail.com
Mon Jul 18 22:41:59 CEST 2005


Hey

Your problem is in the database
I'm surprised how MySQL let you put a space in a field
In MySQL you can't have spaces, as far as I know
Try renaming the field by enteriig to the console and making the alter table 
sentence and put Site_Name instead of Site Name. Then make the query again 
and see what happens

mysql> create table d(autoinc int(4) primary key,Site Name varchar(30));
ERROR 1064: You have an error in your SQL syntax.  Check the manual that 
corresponds to your MySQL server version for the right syntax to use near 
'Name varchar(30))'

This is the error I get from MySQL Server when I try to create a field with 
a space and check the solution:
mysql> create table d(autoinc int(4) primary key,Site_Name varchar(30));
Query OK, 0 rows affected (0.14 sec)

This should fix your problem.

Best Regards to you

Alberto

>From: nephish <nephish at xit.net>
>To: Alberto Troiano <albertito_g at hotmail.com>
>CC: tutor at python.org
>Subject: Re: [Tutor] This should be easy
>Date: Mon, 18 Jul 2005 20:32:55 +0000
>
>ok here is what i have,
>cursor.execute("INSERT INTO History (autoinc, Site Name) VALUES
>(888812, 'Test');")
>
>gives me this
>''' _mysql_exceptions.ProgrammingError : (1064, "You have an error in
>your SQL syntax.  Check the manual that corresponds to your MySQL
>server version for the right syntax to use near 'Name) VALUES (888812,
>'Test')' at line 1") '''
>
>the autoinc field isn't really an auto-increment field, its an int.
>That is left over from the migration from Access.
>
>there are other fields in the table but all can be null.
>
>this line works fine though
>cursor.execute("INSERT INTO History (autoinc) VALUES (888812);")
>
>this line does not
>cursor.execute("INSERT INTO History (Site Name) VALUES ('test');")
>
>can you not have spaces in a field name ? is the quotes gone awry?
>
>dont know what to do next.
>please help !
>
>thanks
>
>
>
>
>On 07/18/2005 03:06:34 PM, Alberto Troiano wrote:
> > I think it would be better for us if you send us the entire line
> > that's giving you problems along with the error its givin you so we
> > can start somewhere
> >
> > Right now I don't know where to look at
> >
> > Best Regards
> >
> > Alberto
> >
> >> From: nephish <nephish at xit.net>
> >> To: tutor at python.org
> >> Subject: [Tutor] This should be easy
> >> Date: Mon, 18 Jul 2005 20:02:38 +0000
> >>
> >> ok here is the error i am getting.
> >> You have an error in your SQL syntax. Check the manual that
> >> corrosponds
> >> to your MySQL version for the right syntax near Name ) values ('one',
> >> 'two')
> >>
> >> thanks
> >>
> >> _______________________________________________
> >> Tutor maillist  -  Tutor at python.org
> >> http://mail.python.org/mailman/listinfo/tutor
> >
> >
> > Gaucho
> >
> >
> >
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor


Gaucho




More information about the Tutor mailing list