96 @pyqtSlot(str) |
97 @pyqtSlot(str) |
97 def on_connections_tableActivated(self, table): |
98 def on_connections_tableActivated(self, table): |
98 """ |
99 """ |
99 Private slot to show the contents of a table. |
100 Private slot to show the contents of a table. |
100 |
101 |
101 @param table name of the table for which to show the contents (string) |
102 @param table name of the table for which to show the contents |
|
103 @type str |
102 """ |
104 """ |
103 self.showTable(table) |
105 self.showTable(table) |
104 |
106 |
105 @pyqtSlot(str) |
107 @pyqtSlot(str) |
106 def on_connections_schemaRequested(self, table): |
108 def on_connections_schemaRequested(self, table): |
107 """ |
109 """ |
108 Private slot to show the schema of a table. |
110 Private slot to show the schema of a table. |
109 |
111 |
110 @param table name of the table for which to show the schema (string) |
112 @param table name of the table for which to show the schema |
|
113 @type str |
111 """ |
114 """ |
112 self.showSchema(table) |
115 self.showSchema(table) |
113 |
116 |
114 @pyqtSlot() |
117 @pyqtSlot() |
115 def on_connections_cleared(self): |
118 def on_connections_cleared(self): |
124 |
127 |
125 def addConnection(self, driver, dbName, user, password, host, port): |
128 def addConnection(self, driver, dbName, user, password, host, port): |
126 """ |
129 """ |
127 Public method to add a database connection. |
130 Public method to add a database connection. |
128 |
131 |
129 @param driver name of the Qt database driver (string) |
132 @param driver name of the Qt database driver |
130 @param dbName name of the database (string) |
133 @type str |
131 @param user user name (string) |
134 @param dbName name of the database |
132 @param password password (string) |
135 @type str |
133 @param host host name (string) |
136 @param user user name |
134 @param port port number (integer) |
137 @type str |
135 @return SQL error object (QSqlError) |
138 @param password password |
|
139 @type str |
|
140 @param host host name |
|
141 @type str |
|
142 @param port port number |
|
143 @type int |
|
144 @return SQL error object |
|
145 @rtype QSqlError |
136 """ |
146 """ |
137 err = QSqlError() |
147 err = QSqlError() |
138 |
148 |
139 self.__class__.cCount += 1 |
149 self.__class__.cCount += 1 |
140 db = QSqlDatabase.addDatabase( |
150 db = QSqlDatabase.addDatabase( |
172 |
182 |
173 def showTable(self, table): |
183 def showTable(self, table): |
174 """ |
184 """ |
175 Public slot to show the contents of a table. |
185 Public slot to show the contents of a table. |
176 |
186 |
177 @param table name of the table to be shown (string) |
187 @param table name of the table to be shown |
|
188 @type str |
178 """ |
189 """ |
179 model = QSqlTableModel(self.table, self.connections.currentDatabase()) |
190 model = QSqlTableModel(self.table, self.connections.currentDatabase()) |
180 model.setEditStrategy(QSqlTableModel.EditStrategy.OnRowChange) |
191 model.setEditStrategy(QSqlTableModel.EditStrategy.OnRowChange) |
181 model.setTable(table) |
192 model.setTable(table) |
182 model.select() |
193 model.select() |
196 |
207 |
197 def showSchema(self, table): |
208 def showSchema(self, table): |
198 """ |
209 """ |
199 Public slot to show the schema of a table. |
210 Public slot to show the schema of a table. |
200 |
211 |
201 @param table name of the table to be shown (string) |
212 @param table name of the table to be shown |
|
213 @type str |
202 """ |
214 """ |
203 rec = self.connections.currentDatabase().record(table) |
215 rec = self.connections.currentDatabase().record(table) |
204 model = QStandardItemModel(self.table) |
216 model = QStandardItemModel(self.table) |
205 |
217 |
206 model.insertRows(0, rec.count()) |
218 model.insertRows(0, rec.count()) |