Converts SQLALchemy Base Classes to AtlasGo HCL.
Project description
Summary
Converts SQLAlchemy models to AtlasGo HCL.
Quickstart
- Run
pip install sqlalchemy2atlas
- Run
sqlalchemy2atlas -h
Driver Support
- PostgreSQL
- 14.x
- Cloud Spanner
- MySQL
- SQLLite
Example
Example of converting a SQLAlchemy module into AtlasGo HCL.
from datetime import datetime
from sqlalchemy.orm import declarative_base
from sqlalchemy import (
Column,
Integer,
String,
DateTime,
CheckConstraint,
ForeignKey,
)
Base = declarative_base()
class User(Base):
__tablename__ = "user"
# Feat: Primary Key
id = Column(Integer, primary_key=True)
# Feat: Column Types
name = Column(String(30))
full_name = Column(String)
age = Column(Integer)
# Feat: Check Constraints
check_age_positive = CheckConstraint(age > 0)
check_age_reasonable = CheckConstraint(age < 200)
class Account(Base):
__tablename__ = "account"
# Feat: Primary Key
id = Column(Integer, primary_key=True)
# Feat: Column Types, Foreign Keys
user_id = Column(Integer, ForeignKey("user.id"), nullable=False)
account_created_at = Column(DateTime, nullable=False)
Into
table "account" {
schema = schema.public
column "id" {
null = false
type = serial
}
column "user_id" {
null = false
type = integer
}
column "account_created_at" {
null = false
type = timestamp
}
primary_key {
columns = [column.id]
}
foreign_key "account_user_id_fkey" {
columns = [column.user_id]
ref_columns = [table.user.column.id]
on_update = NO_ACTION
on_delete = NO_ACTION
}
}
table "user" {
schema = schema.public
column "id" {
null = false
type = serial
}
column "name" {
null = true
type = character_varying(30)
}
column "full_name" {
null = true
type = character_varying
}
column "age" {
null = true
type = integer
}
primary_key {
columns = [column.id]
}
check "user_age_check" {
expr = "(age > 0)"
}
check "user_age_check1" {
expr = "(age < 200)"
}
}
schema "public" {
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlalchemy2atlas-0.1.9.tar.gz.
File metadata
- Download URL: sqlalchemy2atlas-0.1.9.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1023-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7834453eb2eee394dbf35a48b2c33151da2cb314dcb03842d3ee20ef79792e1
|
|
| MD5 |
c4f3fbd615fb12a371bf3e6a5644e802
|
|
| BLAKE2b-256 |
4fbcc45c670cc42a67bd69faa363b3c0391bec299dd9c9e5891d81a8998e617d
|
File details
Details for the file sqlalchemy2atlas-0.1.9-py3-none-any.whl.
File metadata
- Download URL: sqlalchemy2atlas-0.1.9-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1023-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e33e1f22fd5201d9f6bd033cb7e8d7812dce1b6eb9ea3e745706c8baba92de4
|
|
| MD5 |
5a6d33b04afd5cd5a81f9bc7eb5c132a
|
|
| BLAKE2b-256 |
0d3f7e68cc2adb78079c4943fd3ab1ba973d8a8eb6ed8b58d1cc77054fc6b2e8
|