1

Error 1065 'Query was Empty' In python script
I have kept all the create table SQL querys in a text file. Using readLines i am trying to execute the sql commands as per the code mentioned.

file=open("TABLES.txt","r")
for sql in file.readlines():
    self.cursor.execute(sql)

But I am getting Error 1065 ' Query was empty'. More Importantly the tables are being created in the database. The text file is like this

CREATE TABLE TUserDetails (FirstName VarChar(50) NOT NULL, LastName VarChar(50) NOT NULL, EmailId VarChar(50) NOT NULL,Type VarChar(50) NOT NULL,Department VarChar(50) NOT NULL,NoOfIncorrectAttempt Integer NOT NULL,Deleted Bit NOT NULL,UserID VarChar(50) NOT NULL,CONSTRAINT TUserDetailsPK PRIMARY KEY CLUSTERED ( UserID ))

CREATE TABLE TRequests(RequestID VarChar(50) NOT NULL,UserID VarChar(50) NOT NULL,Status SmallInt NOT NULL,TimeOfRequest Timestamp NOT NULL,Deleted Bit NOT NULL,Priority Integer NOT NULL,CONSTRAINT TRequests_PK PRIMARY KEY CLUSTERED ( RequestID ))

I checked running each sql query individually, and it is working file. Now although the tables are being created in the database but i am getting error 1065 as mentioned above

1
  • I am new to python.....and need help urgently.Please Help Commented Mar 9, 2014 at 17:06

1 Answer 1

5

The error message is very clear: The query is empty. You're reading every line and executing it as a SQL query, and your file has a blank line between the CREATE TABLE statements.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.