This is a metamodel for SQL using the Famix metamodel generator.
It uses ODBC to connect to any database and gather basic schema information.
Download a Moose image.
In the Moose image, in a playground (Ctrl+O
, Ctrl+W
), perform:
Metacello new
baseline: 'FamixSQL';
repository: 'github://moosetechnology/FamixSQL:main/src';
load.
Please read first the main documentation here
UML generated with plantUML using the FamixUMLDocumentor (on 2023/10/01)
After loading the project, you should create a connection between Pharo and the database using:
connection := ODBCConnection new.
connection dsn: '<dsn name>'.
connection uid: '<username>'. "Username"
connection pwd: '<password>'. "Password"
connection connect.
Then, you can perform the import in a FamixSQL Model.
importer := FamixSQLODBCImporter new.
importer model: FamixSQLModel new.
importer source: connection.
model := importer import.
model.
Analyse of the database can be performed using Moose Critics. A first set of rule is available in this repo.
A Roassal3 visualisation of the tables and their link is also available in this package and can be opened by executing the folowing script:
tables := ((model allWithType: FamixSQLTable) first: 10) asMooseSpecializedGroup.
(SQLRSTableGroupBuilder new
sourceGroup: tables;
collapseAll;
build;
canvas) open.
One can also perform common request by scripting
(model allWithType: FamixSQLTable) select: [ :table | table columns noneSatisfy: #isPrimaryKeyColumn ]
Many thanks to Julien Deplanque who made the first version of this work. If you intend to manipulate PostgresQL database, his work will fit your need.