I am trying to INSERT some data into a table that has been created in SQL Azure.
SQL Structure
Field 1 DATE
Field 2 INT
Field 3 INT
Python code used:
#I know I have connected to the correct database.
Connection = pyodbc.connect(conn.conn())
cursor = Connection.cursor()
SQLCommand = ('INSERT INTO table_name ([Field 1], [Field 2], [Field 3]) VALUES ('31-Dec-14', 1, 2);')
cursor.execute(SQLCommand)
Connection.commit()
I get the following error
pyodbc.ProgrammingError: ('42S22', "[42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name '31-DEC-2014'. (207)
If I replace it with
SQLCommand = ('INSERT INTO table_name ([Field 1], [Field 2], [Field 3]) VALUES (?, ?, ?);', ('31-DEC-2014',1,2))
cursor.execute(SQLCommand)
Connection.commit()
I get the following error
TypeError: The first argument to execute must be a string or unicode query.
How should I input dates and integers into an SQL azure table via python?
Thanks