File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,27 @@ def _cursor(self):
242242
243243 return CursorWrapper (cursor , self .driver_needs_utf8 )
244244
245+ def _execute_foreach (self , sql , table_names = None ):
246+ cursor = self .cursor ()
247+ if not table_names :
248+ table_names = self .introspection .get_table_list (cursor )
249+ for table_name in table_names :
250+ cursor .execute (sql % self .ops .quote_name (table_name ))
251+
252+ def check_constraints (self , table_names = None ):
253+ self ._execute_foreach ('ALTER TABLE %s WITH CHECK CHECK CONSTRAINT ALL' , table_names )
254+
255+ def disable_constraint_checking (self ):
256+ # Windows Azure SQL Database doesn't support sp_msforeachtable
257+ #cursor.execute('EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT ALL"')
258+ self ._execute_foreach ('ALTER TABLE %s NOCHECK CONSTRAINT ALL' )
259+ return True
260+
261+ def enable_constraint_checking (self ):
262+ # Windows Azure SQL Database doesn't support sp_msforeachtable
263+ #cursor.execute('EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL"')
264+ self .check_constraints ()
265+
245266
246267class CursorWrapper (object ):
247268 """
You can’t perform that action at this time.
0 commit comments