-6

I wrote this program:

con=kinterbasdb.create_database("create database 'D:/ThirdTask/test.db' user 'sysdba' password 'masterkey'")
conn=kinterbasdb.connect(host='localhost',database='D:/ThirdTask/test.db', user='sysdba', password='masterkey')
cur=con.cursor()
s="""
 create table CLIENTS
  (        
     ID   FMTBCD PRIMARY KEY,
     COMPANY   CHAR(50),
     LAST NAME   CHAR(50),
     FIRST NAME   CHAR(50),
     E-MAIL ADDRESS   CHAR(50),
     JOB TITLE   CHAR(50),
     BUSINESS PHONE   CHAR(25),
     HOME PHONE   CHAR(25),
     MOBILE PHONE   CHAR(25),
     FAX NUMBER   CHAR(25),
     ADDRESS   MEMO,
     CITY   CHAR(50),
     STATE/PROVINCE   CHAR(50),
     ZIP/POSTAL CODE   CHAR(15),
     COUNTRY/REGION   CHAR(50),
     WEB-SITE   CHAR(25),
     NOTES   MEMO,
     INCLUDING   BLOB
     )"""
     print s
     cur.execute(s)
     con.close()
     conn.close()

The compiler gives out the following error:

 create table CLIENTS
 (
    ID   FMTBCD PRIMARY KEY,
    COMPANY   CHAR(50),
    LAST NAME   CHAR(50),
    FIRST NAME   CHAR(50),
    E-MAIL ADDRESS   CHAR(50),
    JOB TITLE   CHAR(50),
    BUSINESS PHONE   CHAR(25),
    HOME PHONE   CHAR(25),
    MOBILE PHONE   CHAR(25),
    FAX NUMBER   CHAR(25),
    ADDRESS   MEMO,
    CITY   CHAR(50),
    STATE/PROVINCE   CHAR(50),
    ZIP/POSTAL CODE   CHAR(15),
    COUNTRY/REGION   CHAR(50),
    WEB-SITE   CHAR(25),
    NOTES   MEMO,
    INCLUDING   BLOB
    )

Traceback (most recent call last):
File "D:\ThirdTask\connect.py", line 119, in <module>
      cur.execute(s)
ProgrammingError: (-104, 'isc_dsql_prepare: \n  Dynamic SQL Error\n  SQL error code = -104\n  Token unknown - line 6, column 16\n  CHAR')

What could be the cause of the error?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
dva
  • 47
  • 1
  • 1
  • 6
  • 6
    abundance of `bla` error when reading question. (hint: rephrase the question if you want anyone to read beyond the appalling intro) – xtofl Sep 24 '12 at 10:25
  • As you posed it, few people, if any, will bother answering your question. Please visit http://www.whathaveyoutried.com and follow those instructions. – HerrKaputt Sep 24 '12 at 10:33

1 Answers1

2

You are defining column names with spaces as well as using - dashes and \ slashes. Put such names in double quotes:

s="""
 create table CLIENTS
  (        
     ID   FMTBCD PRIMARY KEY,
     COMPANY   CHAR(50),
     "LAST NAME"   CHAR(50),
     "FIRST NAME"   CHAR(50),
     "E-MAIL ADDRESS"   CHAR(50),
     "JOB TITLE"   CHAR(50),
     "BUSINESS PHONE"   CHAR(25),
     "HOME PHONE"   CHAR(25),
     "MOBILE PHONE"   CHAR(25),
     "FAX NUMBER"   CHAR(25),
     ADDRESS   MEMO,
     CITY   CHAR(50),
     "STATE/PROVINCE"   CHAR(50),
     "ZIP/POSTAL CODE"   CHAR(15),
     "COUNTRY/REGION"   CHAR(50),
     "WEB-SITE"   CHAR(25),
     NOTES   MEMO,
     INCLUDING   BLOB
     )"""

Firebird adheres quite strictly to the ANSI SQL standard, see Interbase/Firebird identifiers for detailed rules on what identifiers you can define with and without quoting.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • as a result, Traceback (most recent call last): File "D:\ThirdTask\connect.py", line 119, in cur.execute(s) ProgrammingError: (-607, 'isc_dsql_prepare: \n Dynamic SQL Error\n SQL error code = -607\n Invalid command\n Specified domain or source column FMTBCD does not exist') – dva Sep 24 '12 at 10:42
  • 2
    @dva: I don't quite know what FMTBcd *is*; it seems to be something to do with Delphi. Have you tried just removing it? It seems you have no idea what you are doing; just throwing a SQL table at Firebird? – Martijn Pieters Sep 24 '12 at 10:46