Mac下Python伪数据库生成器fake2db

git地址
丰富的自定义数据类型

# 安装驱动
➜  ~ pip install mysql-connector-python
➜  ~ fake2db --help
usage: fake2db [-h] [--rows ROWS] [--db DB] [--name NAME] [--host HOST] [--port PORT] [--username USERNAME] [--password PASSWORD] [--custom CUSTOM [CUSTOM ...]] [--locale LOCALE] [--seed SEED]

optional arguments:
  -h, --help            show this help message and exit
  --rows ROWS           Amount of rows desired per table
  --db DB               Db type for creation: sqlite, mysql, postgresql, mongodb, redis, couchdb, to be expanded
  --name NAME           The name to the db to be generated
  --host HOST           Hostname of db
  --port PORT           Port of db
  --username USERNAME   Username
  --password PASSWORD   Password
  --custom CUSTOM [CUSTOM ...]
                        Custom schema for db generation, supports functions that fake-factory provides, see fake2db github repository for options https://github.com/emirozer/fake2db
  --locale LOCALE       The locale of the data to be generated: {bg_BG,cs_CZ,...,zh_CN,zh_TW}. 'en_US' as default
  --seed SEED           Seed value for the random generator
# 自定义数据
➜  ~ fake2db --rows 100 --db mysql --name testfake2db --host 127.0.0.1 --port 3306 --username root --password XXXX --custom name date country --seed 10

mysql> use testfake2db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------------+
| Tables_in_testfake2db |
+-----------------------+
| custom                |
+-----------------------+
1 row in set (0.00 sec)

mysql> desc custom;
+---------+--------------+------+-----+---------+-------+
| Field   | Type         | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| id      | varchar(200) | NO   | PRI | NULL    |       |
| name    | varchar(300) | YES  |     | NULL    |       |
| date    | varchar(300) | YES  |     | NULL    |       |
| country | varchar(300) | YES  |     | NULL    |       |
+---------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> select * from custom limit 10;
+----------------------------------+--------------------+------------+-------------------------------+
| id                               | name               | date       | country                       |
+----------------------------------+--------------------+------------+-------------------------------+
| 00f5bfc5977e48ffb45dfcd59219bbe3 | Mark Cummings      | 2006-04-24 | Pakistan                      |
| 092949e1bf7a4f7e80ad99378eda0844 | Jonathan Wilkinson | 1998-02-05 | Dominican Republic            |
| 0f8b0e0279864e419a60f8e9d9e472ad | Shelly Savage      | 2014-05-22 | Cook Islands                  |
| 1039bee26e5b4bab8a5b29e1d55adef1 | Sarah Hernandez    | 1971-11-01 | Holy See (Vatican City State) |
| 110a7c9f2e11416bbe6adf75ef513bcf | Stephanie Wolfe    | 1998-10-22 | Greenland                     |
| 12309c3a7c8c4f88a03003154bdb768f | Jasmine Perez      | 2004-09-22 | Northern Mariana Islands      |
| 1327bb0eff044d9a96d83b695248b849 | Samantha Valdez    | 1980-11-26 | Antigua and Barbuda           |
| 1586cb8d64984e199bffd050a22ece36 | Sharon Walton      | 2005-07-22 | Saint Helena                  |
| 165e87f57ffa4c8c844b0262a3546322 | Ruth Brown         | 2008-10-16 | Samoa                         |
| 1913c6f0232a495eb7a2b08b0d6ca545 | Krista Terrell     | 1977-03-10 | Svalbard & Jan Mayen Islands  |
+----------------------------------+--------------------+------------+-------------------------------+
10 rows in set (0.00 sec)

# 需要重命名表名
alter table custom rename to users;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容