# 安装驱动
➜ ~ 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;
Mac下Python伪数据库生成器fake2db
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- Python 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资...
- 你在写程序的时候,常常需要用一些假数据来测试功能,比如用户的注册,获取数据列表接口等等,总不能老是 “test.....
- 5月以来,哪怕对市场风向再不敏感的人,也感觉到阵阵凉意。二级市场连续下挫,一级市场融资环境恶化,不论企业融资数量还...