Introdoc (from introspection and document) — a tool for generating .docx documents, containing introspected tables from Microsoft SQL Server databases.
Created for needs of students in Russian colleges, who have to attach tables with structure of databases to their reports for practical works and course projects. Basically, when you have 10+ tables in your database, it's a pain to write them all manually. So, there it is.
- Clone this repository with
git clone https://github.com/GD-alt/introdoc. - Install dependencies with
pip install -r requirements.txt. If you're using poetry, you can runpoetry installinstead. - Now you're able to run the script with
py -m introdoc. If you're a happy Linux user, you can usepython3 -m introdocinstead.
This script uses pyodbc to connect to SQL Server. You might need to install ODBC drivers for your system. If you're using Windows, you can download them from Microsoft site. If you're using Linux… well, you're on your own, I don't use it in everyday life. Good luck!
Introdoc is a command-line tool, which provides hella load of options. Here's a quick overview of them:
| Long name | Short name | Description | Default |
|---|---|---|---|
--output |
-o |
Output document name | output.docx |
--database |
-d |
Database to introspect | master |
--server |
-s |
Server name | (localdb)\mssqllocaldb |
--driver |
-D |
Driver name | ODBC Driver 17 for SQL Server |
--tables |
-t |
Tables to introspect, divided by comma | None |
--language |
-l |
Language to use in tables (ru, en, de) |
en |
--headers |
-h |
If to include table headers into table (flag) | False |
--inullable |
-N |
If to include Nullable? column into table (flag) |
False |
--onatural |
-n |
If included, Nullable column will contain Yes and Nos |
False |
--sections |
-S |
If to separate tables with their names (flag) | False |
py -m introdocwill introspect all tables frommasterdatabase on(localdb)\\mssqllocaldbserver, and save them intooutput.docxfile. Tables will be in English, without headers,Nullable?column,YesandNovalues inNullable?column, and not separated with their names.py -m introdoc -d AdventureWorks -s localhost -D 'ODBC Driver 17 for SQL Server' -t HumanResources.Department,HumanResources.Employee -l ru -h -N -n -swill introspectHumanResources.DepartmentandHumanResources.Employeetables fromAdventureWorksdatabase onlocalhostserver, usingODBC Driver 17 for SQL Serverdriver, and save them intooutput.docxfile. Tables will be in Russian, with headers,Nullable?column,YesandNovalues inNullable?column, and separated with their names.py -m introdoc -d 10210797 -S(my usecase) will introspect all tables from10210797database on(localdb)\\mssqllocaldbserver, and save them intooutput.docxfile. Tables will be in English, without headers,Nullable?column,YesandNovalues inNullable?column, and separated with their names.