make_table

Data_Reduction.GAVRT.mysql.make_table(database, table_data)

Adds or populates a table in the specified database from a dictionary.

Makes a table from the dictionary ‘table_data’ with the keys:

name - the name of the table, a simple string with no spaces
keys - a dictionary whose keys are the (lower-case) keys for the table
       and whose values are the corresponding data types.
data - a list of dictionaries.  Each dictionary corresponds to
       a row in the table. The keys correspond to the keys defined in
       'keys'.

This is useful when the table is created once and for all, or completely replaced. Here’s a small example:

{name: "customers",
 keys: {'name':    'CHAR(20 NOT NULL'),
        'job':     'VARCHAR(20)',
        'sex':     "ENUM('M','F')",
        'hobbies': "SET('chess','sailing','reading','knitting')",
        'birth':   'DATE',
        'balance': 'FLOAT'},
data: [{name: "Sam", job: "carpenter", birth: 1950-07-21, balance: 5.25},
       {job: "nurse", name: "Sally", balance: 8.50, birth: 1960-3-15}]