Import sqlalchemy models from json/csv or export db data to json/csv.
Project description
SQLAlchemy data manager
Import SQLAlchemy models from json/csv or export db data to json/csv.
Examples
# models.py
from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, Integer, String
Base = declarative_base()
class User(Base):
__tablename__ = "users"
id = Column(Integer, autoincrement=True, unique=True, primary_key=True, nullable=False)
first_name = Column(String(255), nullable=False)
last_name = Column(String(255), nullable=False)
email = Column(String(255), nullable=False)
# settings.py
import os
from .models import User
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
TEST_DATA_PATH = os.path.join(BASE_PATH, "test_data")
USERS_JSON = os.path.join(TEST_DATA_PATH, "users.json")
USERS_CSV = os.path.join(TEST_DATA_PATH, "users.csv")
MODEL_FILE_JSON_MAPPING = {
User: USERS_JSON,
}
MODEL_FILE_CSV_MAPPING = {User: USERS_CSV}
# Run
from sqlalchemy_data_manager import CSVDataManager, JsonDataManager
json_manager = JsonDataManager()
json_manager.import_data() # Import data from json
json_manager.export_data() # Export data to json
csv_manager = CSVDataManager()
csv_manager.import_data() # Import data from csv
csv_manager.export_data() # Export data to csv
Required
- python >=3.11, <4.0
- SQLAlchemy >=1.4.36, <2.1.0
Installation
pip install sqlalchemy-data-manager
Contributing
Before contributing please read our contributing guidelines.
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 sqlalchemy_data_manager-0.0.1.tar.gz.
File metadata
- Download URL: sqlalchemy_data_manager-0.0.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1022acb7d5eaaa2da80b92c6f99ba8380e555d8764e1c1a90e9383995c46e53d
|
|
| MD5 |
389314406ee3585823dec8c43c37424d
|
|
| BLAKE2b-256 |
0db611a202f3cd789df0032c9a108824f935f6558655cd66e346b06977b90486
|
File details
Details for the file sqlalchemy_data_manager-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sqlalchemy_data_manager-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81472c46318efc2b5a94558c21904978a62532f7ec9a3b63b4e65c87d17eb453
|
|
| MD5 |
e8c535b8c22596fc61f9242540f70cad
|
|
| BLAKE2b-256 |
680c9de31b0fcab4e76106e32c76dd65a7ef6161779c0d07a40f7bdc7720da5a
|