jeffsantos / FamixSQL

A Metamodel for SQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FamixSQL

This is a metamodel for SQL using the Famix metamodel generator.

It uses ODBC to connect to any database and gather basic schema information.

Installation

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.

Main documentation

Please read first the main documentation here

UML

UML generated with plantUML using the FamixUMLDocumentor (on 2023/10/01)

image

Usages

Model Loading

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 the database

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.

Common request

One can also perform common request by scripting

Table without primary key

(model allWithType: FamixSQLTable) select: [ :table | table columns noneSatisfy: #isPrimaryKeyColumn ]

Acknowledgement

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.

About

A Metamodel for SQL

License:MIT License


Languages

Language:Smalltalk 100.0%