Skip to content

Instantly share code, notes, and snippets.

View sualeh's full-sized avatar
⚠️
404 Not Found

Sualeh Fatehi sualeh

⚠️
404 Not Found
View GitHub Profile
@sualeh
sualeh / Main.java
Created September 27, 2023 22:19 — forked from Whatshiywl/Main.java
SchemaCrawler API serialize
package foo.bar;
import java.nio.file.Paths;
import java.util.logging.Level;
import schemacrawler.schemacrawler.LimitOptionsBuilder;
import schemacrawler.schemacrawler.LoadOptionsBuilder;
import schemacrawler.schemacrawler.SchemaCrawlerOptions;
import schemacrawler.schemacrawler.SchemaCrawlerOptionsBuilder;
import schemacrawler.schemacrawler.SchemaInfoLevelBuilder;
@sualeh
sualeh / SchemaCrawlerDiagramGenerator.java
Created May 3, 2023 20:06
Generate Schema Diagrams with SchemaCrawler
package de.dpma.azubi.markenschema.schemacrawler;
import static us.fatehi.utility.Utility.isBlank;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
@sualeh
sualeh / ApiExampleAthena.java
Created April 22, 2023 12:48
SchemaCrawler example code for AWS Athena
package com.example;
import java.sql.Connection;
import java.util.logging.Level;
import schemacrawler.crawl.ConnectionInfoBuilder;
import schemacrawler.schema.Catalog;
import schemacrawler.schema.Column;
import schemacrawler.schema.Schema;
import schemacrawler.schema.Table;
import schemacrawler.schemacrawler.LimitOptionsBuilder;
@sualeh
sualeh / README.md
Last active January 26, 2023 21:30
How to Document Your Trino Database with One Command (and Nothing to Install)

How to Document Your Trino Database with One Command (and Nothing to Install)

Ever wondered what the tables in your Trino database look like? Generate a text file of your Trino database with one command. You can run this on any system that has Docker installed.

For now, create a Trino database in a Docker container. Later you can use the same technique to conect to your own Trino database. Create two Docker Compose files for the Trino and SchemaCrawler containers from the GitHub gist for this article.

Then open a command shell in the same folder that you created these files, and run:

docker-compose -f schemacrawler.yaml -f trino.yaml up -d
@sualeh
sualeh / README.md
Last active April 19, 2024 13:54
Create Nice-looking Schema Diagrams in PlantUML

Create Nice-looking Schema Diagrams in PlantUML

PlantUML is a descriptive language to generate a number of types of software diagrams, such as sequence, class, deployment and state diagrams, and many others. PlantUML does not generate very good-looking schema diagrams out of the box, but it supports themes and preprocessed macros. If you use themes and macros, you can not only use a simplified syntax, but also generate beautiful diagrams.

Here is an example of a PlantUML schema diagram, and we will build up the code to generate it.

Schema diagram

To start, describe your schemas, tables and columns using this syntax as an example.

@sualeh
sualeh / README.md
Last active January 22, 2023 21:45
How to Document Your Cassandra Database with One Command (and Nothing to Install)

How to Document Your Cassandra Database with One Command (and Nothing to Install)

Ever wondered what the tables in your Cassandra database look like? Generate a text file of your Cassandra database with one command. You can run this on any system that has Docker installed.

For now, create a Cassandra database in a Docker container. Later you can use the same technique to conect to your own Cassandra database. Create two Docker Compose files for the Cassandra and SchemaCrawler containers. Also create one more with the CQL database creation script. You can find these files in the GitHub gist for this article.

Then open a command shell in the same folder that you created these files, and run:

docker-compose -f schemacrawler.yml -f cassandra.yml up -d
@sualeh
sualeh / plantuml.py
Created November 25, 2022 02:27
SchemaCrawler Plant UML Generation
from __future__ import print_function
import re
from schemacrawler.schema import TableRelationshipType # pylint: disable=import-error
from schemacrawler.schemacrawler import IdentifierQuotingStrategy # pylint: disable=import-error
from schemacrawler.utility import MetaDataUtility # pylint: disable=import-error
print("@startuml")
print("""
hide empty methods
!define schema(x) package x <<Rectangle>>
@sualeh
sualeh / README.md
Created November 20, 2022 00:07
Run Custom Scripts with SchemaCrawler

Run Custom Scripts with SchemaCrawler

See docker-compose and mermaid diagrams

How To Generate mermaid diagrams

  • Save all the files from this gist into a single directory
  • Run docker-compose -f schemacrawler-sqlite-mermaid.yml
"""Test for lab module."""
from unittest import TestCase
from schedule import Schedule
from unittest import skip
class TestLab3ForGrading(TestCase):
"""Test for Lab 3."""
def test_schedule_happy_path(self):
@sualeh
sualeh / test_lab3_for_grading.py
Created September 19, 2022 18:02
COMP-880 Lab 3 Grading Tests
"""Tests for lab module."""
import pytest
import schedule
def test_schedule_0():
"""Tests an argument of None, and ensures that no error occurs."""
sch = schedule.Schedule(None, ['Math'])
classes: list = sch.classes_for('Mon')
for day in ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']: