I am writing a function which stores tweets pulled with tweepy in Python into a database(SQL server). I have written the following code to insert into the SQL DB
conn = pymssql.connect(host,user,passwd,DB)
cursor = conn.cursor()
def insertTweet(user,text,image):
query = "INSERT INTO [TWEETS].[dbo].[TWEET_INFO] ]
(username,text,image_url,approved)\
values (user, text, image, 0)"
cursor.execute(query)
This is a very simple function which shouldn't really give an error, but I do get one saying that text is an invalid column name. :
Traceback (most recent call last):
File "db_connect.py", line 35, in <module>
insertTweet(user,text,image)
File "db_connect.py", line 19, in insertTweet
cursor.execute(query)
File "src\pymssql.pyx", line 465, in pymssql.Cursor.execute
pymssql.ProgrammingError: (207, b"Invalid column name 'text'.DB-Lib error
messag
e 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL
Ser
ver\nDB-Lib error message 20018, severity 16:\nGeneral SQL Server error:
Check m
essages from the SQL Server\n")
Following is the DB structure :
SELECT TOP 1000 [Id]
,[username]
,[text]
,[image_url]
,[approved]
FROM [TWEETS].[dbo].[TWEET_INFO]
I am not sure how to figure this out. I am able to add by manually running a query in sql studio