Maybe one of you can help with this. I've got some data that I grabbed from a cobbler *.json file using simplejson.load(). Heres what the data looks like:
In [120]: print mydata.keys() ['comment', 'kickstart', 'name_servers_search', 'ks_meta', 'kernel_options_post', 'image', 'redhat_management_key', 'power_type', 'power_user', 'kernel_options', 'virt_file_size', 'mtime', 'template_files', 'gateway', 'uid', 'virt_cpus', 'hostname', 'virt_type', 'mgmt_classes', 'power_pass', 'netboot_enabled', 'profile', 'virt_bridge', 'parent', 'virt_path', 'interfaces', 'power_address', 'name_servers', 'name', 'owners', 'ctime', 'virt_ram', 'power_id', 'random_id', 'server', 'redhat_management_server', 'depth'] In [121]: print mydata.values() ['Virtual Machine', '<<inherit>>', ['subdomain.company.com', 'company.com'], {'puppet_environment': 'development'}, {}, '', '~', 'apc_snmp', '', {'dns': '10.10.132.12'}, 160, 1286408237.2311871, {}, '10.10.32.3', 'asIjeKJIDOOUuUIDSwOTY', 16, 'webservice-app16.subdomain.company.com', '<<inherit>>', [], '', True, 'rhel5-server-64-domU', '<<inherit>>', '', '<<inherit>>', {'eth0': {'dhcp_tag': '', 'subnet': '255.255.255.0', 'virt_bridge': 'xenbr0', 'static_routes': ['10.10.0.0/255.255.0.0:10.10.32.3', '10.10.0.0/255.255.0.0:10.10.32.3'], 'dns_name': 'webservice-app16.subdomain.company.com', 'bonding': '', 'static': True, 'bonding_opts': '', 'mac_address': '00:16:3e:aa:aa:aa', 'bonding_master': '', 'ip_address': '10.10.32.219'}}, '', ['10.10.132.12', '10.10.132.13'], 'webservice-app16.subdomain.company.com', ['scarolan'], 1277755073.144805, 11749, '', '7oWY', '<<inherit>>', '~', 2] I have a database with a table called "systems" that contains an auto-increment id field, as well as fields for each of the keys in mydata.keys(). But I can't seem to get the syntax to import mydata.values() into the table. I think the problem may be that some of the items in my list are dictionaries or lists... What would be the quickest and most straightforward way to do this? My table is below if you need a reference, sorry for the ugly formatting: mysql> show columns in systems; +--------------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | comment | varchar(255) | YES | | NULL | | | kickstart | varchar(255) | YES | | NULL | | | name_servers_search | varchar(255) | YES | | NULL | | | ks_meta | varchar(255) | YES | | NULL | | | kernel_options_post | varchar(255) | YES | | NULL | | | image | varchar(255) | YES | | NULL | | | redhat_management_key | varchar(255) | YES | | NULL | | | power_type | varchar(255) | YES | | NULL | | | power_user | varchar(255) | YES | | NULL | | | kernel_options | varchar(255) | YES | | NULL | | | virt_file_size | int(11) | YES | | NULL | | | mtime | int(11) | YES | | NULL | | | template_files | varchar(255) | YES | | NULL | | | gateway | varchar(255) | YES | | NULL | | | uid | varchar(255) | YES | | NULL | | | virt_cpus | smallint(64) | YES | | NULL | | | hostname | varchar(255) | YES | | NULL | | | virt_type | varchar(255) | YES | | NULL | | | mgmt_classes | varchar(255) | YES | | NULL | | | power_pass | varchar(255) | YES | | NULL | | | netboot_enabled | varchar(255) | YES | | NULL | | | profile | varchar(255) | YES | | NULL | | | virt_bridge | varchar(255) | YES | | NULL | | | parent | varchar(255) | YES | | NULL | | | virt_path | varchar(255) | YES | | NULL | | | interfaces | text | YES | | NULL | | | power_address | varchar(255) | YES | | NULL | | | name_servers | varchar(255) | YES | | NULL | | | name | varchar(255) | YES | | NULL | | | owners | varchar(255) | YES | | NULL | | | ctime | int(11) | YES | | NULL | | | virt_ram | int(11) | YES | | NULL | | | power_id | varchar(255) | YES | | NULL | | | random_id | varchar(255) | YES | | NULL | | | server | varchar(255) | YES | | NULL | | | redhat_management_server | varchar(255) | YES | | NULL | | | depth | tinyint(4) | YES | | NULL | | +--------------------------+--------------+------+-----+---------+----------------+ _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor