MySQLdb Error

Chris Angelico rosuav at
Wed Jan 11 04:00:07 EST 2012

On Wed, Jan 11, 2012 at 6:57 PM, Emeka <emekamicro at> wrote:
> CREATE TABLE AddressTables ( AddressTables_id int (9) unsigned
> primary key auto_increment not null,  city_name char(40) ,  state_name
> varchar,  street_number int,  country_name varchar,  street_name char(40) ,
> user_name char(40) references usertables(name))
> _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 '  street_number int,  country_name varchar,
>  street_name char(40) , user_name ch' at line 1")

You're getting an error back from the database. The message suggests
that you look around the place cited for some kind of syntactic error.
See if you can find the error; often, in situations like this, the
actual error is a little bit before what's pointed to.

Have a look, I'll wait.

Spoiler alert! Try figuring it out yourself before you scroll down.

You've been warned! There are spoilers ahead.

Okay. The problem is that MySQL requires varchar to be followed by a
length: varchar(255) or varchar(32) or whatever. The use of naked
'varchar' is a PostgreSQL feature only.

Hope that helps!

Chris Angelico

More information about the Python-list mailing list