how can i list MySQL databases in a Python array -


i working on piece of software can store clients , jobs doing them in mysql database, ui work way want need have every 1 of databases or tables in array reference later. example

mysqltables = [customers,clients,jobs] mysqltables[0] = [joshua,alex,james] mysqltables[0][0] = ["computer issue"] 

this way can reference , display information in frontend ui other solution of displaying visual navigation in pyqt4 using tree widget appreciated

i still pretty new using mysql python , having trouble understanding everything, have found don't understand it

how list tables in databases in sql server in single result set?

from can depict might wanting similar have no idea how implement , not contain job information of client.

i wrote similar project did, had database interface in gui, , allowed user edit , add entries database without having go mysql workbench.

you're going need 2 functions interact database, 1 retrieve entries, , 1 execute changes.

this code retrieve information database using sqlalchemy.

def get_info():     sql = text('select id, '                    'serial_number, '                    'weight_name, '                    'units, '                    'nominal, '                    'customer_name, '                    'density, '                    'density_uncert , '                    'volumetric_exp, '                    'comment '                    'from weights_external '                    'order id ')      return self.engine.execute(sql).fetchall() 

this selects id, serial number, units, etc. table called "weights_external", ordering id. self.engine.execute(sql).fetchall() returns generator (i think, might list don't remember off top of head sorry!) can loop through , results. in example, i'm getting 10 columns table. if table had 100 rows, function return list length 100, , each element of list list length 10, each containing information 1 column.

i store length-100 list in variable, , use variable populate qtablewidget gui.

i have separate button bring sub-window allows user add row. code similar get_info() except updating or inserting table (you can on sqlalchemy or mysql documentation). basically, you'll have similar this:

def push_data(self, data):     table = self.weights_external.insert()     self.engine.execute(table.values(id=data['id'],                                      serial_number=data['serial_num'],                                      ...                                      comment=data['comment'])) 

i left out stuff in middle sake of time , space, these few snippets of code should allow retrieve data database, put qtablewidget or qobject, , allow user change data push of button. if have questions, please comment!


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -