Open-Source
developers tool that provides simple helpers for legacy databases introspection. Crafted on top of Python
and Peewee.
- 👉 Free support via Email and Discord
- 👉 More Developer Tools - provided by AppSeed
Features
Peewee
DB Reflection- Supported DB:
- SQLite, MySql, PostgreSQL
- DbWrapper Class:
print_all_models()
- returns all tablesprint_db_model
- print table definitiondump_tables()
- Dump SQL definitions (all tables)dump_tables_data()
- Dump database content (all tables)
Clone Sources (this repo)
$ git clone https://github.com/app-generator/devtool-db.git
$ cd devtool-db
Install Modules using a Virtual Environment
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt
Or for Windows-based Systems
$ virtualenv env
$ .\env\Scripts\activate
$
$ # Install modules - SQLite Database
$ pip3 install -r requirements.txt
Launch the Python console
$ python
>>>
>>> from util import * # import helpers
>>>
>>> db_sqlite = DbWrapper() # invoke the Base Class
>>> db_sqlite.driver = COMMON.DB_SQLITE # set driver
>>> db_sqlite.db_name = 'samples/api-django.sqlite3' # set db name
>>> db_sqlite.connect() # connect
True
>>> db_sqlite.load_models() # load DB SChema
True
>>> db_sqlite.dump_tables() # Dump tables definitions
True
>>> db_sqlite.dump_tables_data() # Dump data
> Dump data for [api_user_user]
> Dump data for [api_authentication_activesession]
> Dump data for [auth_group]
> Dump data for [api_user_user_groups]
> Dump data for [django_content_type]
> Dump data for [auth_permission]
> Dump data for [api_user_user_user_permissions]
> Dump data for [auth_group_permissions]
> Dump data for [django_admin_log]
> Dump data for [django_migrations]
> Dump data for [django_session]
True
>>> db_sqlite.reset() # reset the Class data
>>>
At this point, the tables and data are saved in the output directory.
$ cd output ; ls
$ SQLITE.sql
$ SQLITE_api_user_user.sql
$ SQLITE_auth_permission.sql
$ SQLITE_django_content_type.sql
$ SQLITE_django_migrations.sql
Database Introspection Tool - Provided by AppSeed App Generator.