Skip to content

mzarnitsa/dbmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dbmap

Database mapping tool. Builds relational diagram of RDBMS tables.

  • Works with ANSI infromation_schema tables, thus compatible with different database engines. Tested with MS SQL and PostgreSQL.
  • Runs in python 2.x or 3.x
  • Produces GraphViz text files. Those could be exported to PDF or image files.

##Dependencies

  • FreeTDS
  • pymssql
  • sqlalchemy

##Automatically Generated Usage Message usage: dbmap.py [-h] [-p PASSWORD] [-f OUTPUT_FILE_NAME] [-s SCHEMAS] [-t TABLES] [-n] database_type host_name database_name login_name

Build a relationship diagram of a RDMS database. Produces GraphViz file (.gv). You can open it with GraphVis to view the actual diagram.

positional arguments: database_type Database engine type in SQL Alchemy. You can google them with string like "sqlalchemy engine configuration". Here is a URL with current version of SQL Alchemy: http://docs.sqlalchemy.org/en/rel_0_9/cor e/engines.html. EXAMPLES: postgresql+psycopg2, mssql+pymssql host_name SQL Server host name database_name Source database name login_name Login name

optional arguments: -h, --help show this help message and exit -p PASSWORD, --password PASSWORD Password for the login_name -f OUTPUT_FILE_NAME, --file OUTPUT_FILE_NAME If not provided, output will be printed to standard output. -s SCHEMAS, --schemas SCHEMAS Comma separated (no spaces) list of schemas to make relationship diagram for. If not provided, all schemas will be processed. -n, --names-only User table names only, no column information will be printed.


##Example:

python3 mssql2pg.py SqlServer PgConversionExample user1 p4ssw0rd -f example.sql -d conversion_example -u python dbmap.py postgresql localhost db user -s wiki -f wiki.gv


##Output:

digraph database_schema { rankdir=RL; node [shape=plaintext] splines=compound

Blog_Comments[label=<
Blog.Comments
CommentIDint
PostIDint
Titlenvarchar(300)
Contentnvarchar(max)
AnonymousFlagbit
>];
Blog_Posts[label=<
Blog.Posts
PostIDint
ModuleIDint
Titlenvarchar(300)
Contentnvarchar(max)
Previewnvarchar(2000)
FriendlyUrlnvarchar(300)
>];
Blog_Visits[label=<
Blog.Visits
IDint
PostIDint
UserIDint
VisitDateTimedatetime
>];
node [shape=recorder style=filled fillcolor=lightgray]

Blog_Visits:PostID -> Blog_Posts:PostID_TO[arrowhead=normal arrowtail=tee dir=both]
Blog_Comments:PostID -> Blog_Posts:PostID_TO[arrowhead=normal arrowtail=tee dir=both]

}

About

SQL database relational diagram builder.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages