0

How to fast add this structure to mysql table (with same col. name)? There is around 15,000 similar records, twitch here can be not set with some records all other are in all records. I work with python 2.7.9 and MySQL 5.5+

print(data)
>>>[
        {
            u'account': {
                u'challenges': {u'total': 0
                },
                u'twitch': {u'name': u'lgt_justice'
                },
                u'name': u'Dawwwis'
            },
            u'character': {
                u'class': u'Witch',
                u'experience': 4250334444,
                u'level': 100,
                u'name': u'Em_Jake'
            },
            u'dead': False,
            u'online': False,
            u'rank': 1,
        },
        ...  # around 15,000 entries
    ]

MySQL table:

CREATE TABLE `acc` (
    `challenges` TINYINT UNSIGNED NOT NULL ,
    `twitch` VARCHAR(30) NULL ,
    `accName` VARCHAR(30) NOT NULL ,
    `charName` VARCHAR(30) NOT NULL ,
    `class` VARCHAR NOT NULL ,
    `exp` INT UNSIGNED NOT NULL ,
    `lvl` TINYINT UNSIGNED NOT NULL ,
    `dead` BOOLEAN NOT NULL ,
    `online` BOOLEAN NOT NULL ,
    `rank` TINYINT UNSIGNED NOT NULL );

challenges -> account.challenges.total
twitch -> account.twitch.name (this can be not set)
accName -> account.name
charName -> character.name
class -> character.class
exp -> character.experience
lvl -> character.lvl
dead -> dead
online -> online
rank -> rank

XnIcRaM
  • 263
  • 1
  • 3
  • 12
  • 1. This is a tree like structure. You want more than one table. 2. Did you try anything? – khajvah Feb 11 '15 at 07:41
  • provide your schema of mysql-table you want to create.. is there multiple tables you wanna create?? – kid Feb 11 '15 at 07:48

1 Answers1

0

create your schema create table in mysql

now use python-mysql package and follow How to use python mysqldb to insert many rows at once which illustrates how to insert large amount of data in mysql using python.

Community
  • 1
  • 1
kid
  • 153
  • 10