Menu

column name is invalid

2009-02-09
2013-04-29
  • Antonio Fittipaldi

    hi all,

    I'm using pymssql 1.0.1 (on Python 2.4.5) and FreeTDS 0.82 under Ubuntu 8.04.2 Server to connect this machine to a remote MS SQL Server 2000 database.
    I make connection with no problems but, using this code:

    import pymssql
    conn = pymssql.connect(host='myhost', user='myuser', password='mypassword', database='mydatabase')
    cur = conn.cursor()
    cur.execute('SELECT TOP 2 * FROM tablename WHERE columnname=LAMACCHIA')
    rows = cur.fetchall()
    print rows
    conn.close()

    I get:

    pymssql.DatabaseError: internal error: SQL Server message 207, severity 16, state 3, line 1:
    The column name 'LAMACCHIA' is invalid (I'm translating from Italian, here).
    DB-Lib error message 207, severity 16:
    General SQL Server error: Check messages from the SQL Server

    columname contains 32 chars length values. If I try a query without a WHERE section I have no problems.
    how can I fix this?

    thank you very much. :)

    greetings

     
    • bugfreeit

      bugfreeit - 2009-02-09

      I think you need to quote 'LAMACCHIA'

      cur.execute("SELECT TOP 2 * FROM tablename WHERE columnname='LAMACCHIA'")

      stefano

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.