SQLAlchemy sync data
Synchronization of data from different sources into one database using SQLAlchemy.
Examples
# models.py
from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, Integer, String
CommonBase = declarative_base()
class User(CommonBase):
__tablename__ = "old_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)
username = Column(String(255), nullable=False)
# getters.py
from sqlalchemy_sync_data.getters import SQLiteGetter
class UserGetter(SQLiteGetter):
template_query = """select id, first_name, last_name, email from users"""
connection_settings = {"database": "sqlalchemy_sync_data.sqlite"}
# handlers.py
from sqlalchemy_sync_data.handlers import BaseHandler
from .getters import UserGetter
from .models import User
class UserHandler(BaseHandler):
model = User
db_fields_to_model_mapping = {
"id": "id",
"first_name": "first_name",
"last_name": "last_name",
"email": "username",
}
field_name_as_external_id = 'id'
getter_class = UserGetter
# synchronizators.py
from sqlalchemy_sync_data.synchronizator import BaseSyncronizator
from .handlers import UserHandler
class UserSyncronizator(BaseSyncronizator):
handler_classes = (UserHandler,)
# Run sync data
from .synchronizators import UserSyncronizator
syncronizator = UserSyncronizator()
syncronizator.run()
Environment variables
SQLALCHEMY_SYNC_DATA_LOCAL_TIMEZONE - setting time zone (default value "UTC").
Required
- python >=3.11, <4.0
- fastapi >=0.100.0, <1.0
- SQLAlchemy >=1.4.36, <2.1.0
- requests >=2.32.3
- psycopg2 >=2.9.5
- pytz >=2020.1
- environs >=9.3.1
Installation
pip install sqlalchemy-sync-data
Contribution
You can run tests with pytest.
pip install poetry
poetry install
pytest
Metadata
Release files for sqlalchemy-sync-data 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqlalchemy_sync_data-0.0.1.tar.gz | 12.1 kB | Without provenance | Details for sqlalchemy_sync_data-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlalchemy_sync_data-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for sqlalchemy_sync_data-0.0.1-py3-none-any.whl |
Total release size: 26.7 kB
Release files / sqlalchemy_sync_data-0.0.1.tar.gz
| Download URL | sqlalchemy_sync_data-0.0.1.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
960c0182536146f80f61b1fd3d935961aa5eb04deb7a8d8f3c6ae29eedcbbcb3
|
|
BLAKE2b-256 checksum How to use checksums |
f5b16bc35e9b663136a3296c3d8b8cc687c6af08c81c756e6825a586b4f0de83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1015-azure
|
Release files / sqlalchemy_sync_data-0.0.1-py3-none-any.whl
| Download URL | sqlalchemy_sync_data-0.0.1-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9dec67820935257caf3abadb0026c1d5f4d8acb66b7d6265557d29748985af2a
|
|
BLAKE2b-256 checksum How to use checksums |
e5283d2c406329816bb379830a1fd3d8b9e49271b4c90bcc96b7faa7232e19df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1015-azure
|
Security for sqlalchemy-sync-data 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.