Mercurial > repos > yufei-luo > s_mart
comparison SMART/Java/Python/mySql/MySqlConnection.py @ 46:169d364ddd91
Uploaded
| author | m-zytnicki |
|---|---|
| date | Mon, 30 Sep 2013 03:19:26 -0400 |
| parents | 44d5973c188c |
| children |
comparison
equal
deleted
inserted
replaced
| 45:e454402ba9d9 | 46:169d364ddd91 |
|---|---|
| 86 for cpt, command in enumerate(commands): | 86 for cpt, command in enumerate(commands): |
| 87 query.execute(command) | 87 query.execute(command) |
| 88 self.connection.commit() | 88 self.connection.commit() |
| 89 | 89 |
| 90 | 90 |
| 91 def executeManyFormattedQueries(self, command, lines, insertion = False): | |
| 92 cursor = self.connection.cursor() | |
| 93 query = MySqlQuery(cursor, self.verbosity) | |
| 94 for line in lines: | |
| 95 result = query.executeFormat(command, line) | |
| 96 self.connection.commit() | |
| 97 if insertion: | |
| 98 return result | |
| 99 else: | |
| 100 return query | |
| 101 | |
| 102 | |
| 103 def executeManyQueriesIterator(self, table): | 91 def executeManyQueriesIterator(self, table): |
| 104 cursor = self.connection.cursor() | 92 cursor = self.connection.cursor() |
| 105 query = MySqlQuery(cursor, self.verbosity) | 93 query = MySqlQuery(cursor, self.verbosity) |
| 106 try: | 94 try: |
| 107 for command in table.getIterator(): | 95 for command in table.getIterator(): |
| 111 for command in table.getIterator(): | 99 for command in table.getIterator(): |
| 112 query.execute(command) | 100 query.execute(command) |
| 113 self.connection.commit() | 101 self.connection.commit() |
| 114 | 102 |
| 115 | 103 |
| 116 def executeManyFormattedQueriesIterator(self, table): | 104 def executeFormattedQuery(self, command, *parameters): |
| 117 cursor = self.connection.cursor() | 105 cursor = self.connection.cursor() |
| 118 query = MySqlQuery(cursor, self.verbosity) | 106 query = MySqlQuery(cursor, self.verbosity) |
| 119 try: | 107 query.executeFormat(command, parameters) |
| 120 for command, values in table.getIterator(): | |
| 121 query.executeFormat(command, values) | |
| 122 self.connection.commit() | |
| 123 except: | |
| 124 for command, values in table.getIterator(): | |
| 125 query.execute(command, values) | |
| 126 self.connection.commit() | |
| 127 | |
| 128 | |
| 129 def executeFormattedQuery(self, command, parameters, insertion = False): | |
| 130 cursor = self.connection.cursor() | |
| 131 query = MySqlQuery(cursor, self.verbosity) | |
| 132 result = query.executeFormat(command, parameters) | |
| 133 self.connection.commit() | 108 self.connection.commit() |
| 134 if insertion: | 109 return query |
| 135 return result | |
| 136 else: | |
| 137 return query |
