Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params # Don't do that with untrusted inputs
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transactionUsing "GO" within a transaction.

Then it should be fine.

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params # Don't do that with untrusted inputs
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transaction.

Then it should be fine.

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params # Don't do that with untrusted inputs
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transaction.

Then it should be fine.

deleted 3 characters in body
Source Link
Maresh
  • 4.7k
  • 1
  • 27
  • 30

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params # Don't do that if with untrusted inputs
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transaction.

Then it should be fine.

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params # Don't do that if with untrusted inputs
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transaction.

Then it should be fine.

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params # Don't do that with untrusted inputs
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transaction.

Then it should be fine.

added 41 characters in body
Source Link
Maresh
  • 4.7k
  • 1
  • 27
  • 30

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params # Don't do that if with untrusted inputs
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transaction.

Then it should be fine.

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transaction.

Then it should be fine.

Yes it is possible to do it like that. I often do so, it is cleaner that hardcoding the SQL in your code.

Can you add the SQL to your post? there's probably a messed up character somewhere.

I do it like that (with pyodbc):

with open('%smysql.sql' % SQL_DIR) as f: 
            sql = f.read() % params # Don't do that if with untrusted inputs
            cursor.execute(sql)
            cursor.commit()
            cursor.close()

EDIT: Remove all the GO it's not an real SQL statement. Check this answer: Using "GO" within a transaction.

Then it should be fine.

added 182 characters in body
Source Link
Maresh
  • 4.7k
  • 1
  • 27
  • 30
Loading
Source Link
Maresh
  • 4.7k
  • 1
  • 27
  • 30
Loading