This project has been archived by its maintainers, and is no longer receiving any updates.
Aftonfalk
Aftonfalk is a module that makes it easier to interact with microsoft sql server. You can see it as an extension to pyodbc
How to install
pip install aftonfalk
Example usage
Instantiate a driver:
driver = MssqlDriver(
dsn="mssql://sa:Password1!@host.docker.internal:31433",
driver=r"{ODBC Driver 18 for SQL Server}"
)
Dropping a table using execute
driver.execute(sql=f"DROP TABLE source_system.schema.table;")
read & write data
data = driver.read(query="select * from tablex")
driver.write(sql="INSERT INTO tablex (column_name) VALUES ('column_value')", data=data)
Manage tables. Generate them programatically.
from aftonfalk.mssql.enums_ import (
SqlServerDataType,
SqlServerTimeZone,
WriteMode,
SqlServerIndexType,
)
from aftonfalk.mssql.types_ import Column, Table, Index, Path
source_database = "source_database"
source_schema = "source_schema"
destination_database = "destination_database"
destination_schema = "destination_schema"
DATA_MODIFIED = Column(
name="data_modified", data_type="DATETIMEOFFSET", constraints="NOT NULL"
)
DEFAULT_COLUMNS = [
Column(name="metadata_modified", data_type="DATETIMEOFFSET", constraints="NOT NULL"),
DATA_MODIFIED,
Column(name="data", data_type="NVARCHAR(MAX)", constraints="NOT NULL"),
]
table_and_key = {
"FactTable": "FactKey",
"Dimensiontable": "DimensionKey"
}
tables = {}
for name, key in table_and_key.items():
tables[name] = Table(
source_path=Path(database=source_database, schema=source_schema, table=name),
destination_path=Path(database=destination_database, schema=destination_schema, table=name),
source_data_modified_column_name="RowUpdatedAt",
timezone=SqlServerTimeZone.CENTRAL_EUROPEAN_STANDARD_TIME,
default_columns=DEFAULT_COLUMNS,
write_mode=WriteMode.APPEND,
batch_size=200,
unique_columns=[
Column(
name=f"{key}",
data_type=SqlServerDataType.NVARCHAR.with_length(50),
constraints="NOT NULL",
)
],
indexes=[
Index(
index_type=SqlServerIndexType.NONCLUSTERED,
columns=[DATA_MODIFIED]
)
]
)
then you can do things like easily:
creating tables
driver.create_table(path=table.destination_path, ddl=table.table_ddl())
inserting into tables
data = ...
driver.write(sql=table.insert_sql(), data=data)
Metadata
Release files for aftonfalk 1.7.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 |
|---|---|---|---|---|
| aftonfalk-1.7.1.tar.gz | 16.0 kB | Without provenance | Details for aftonfalk-1.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aftonfalk-1.7.1-py3-none-any.whl | Python 3 | none | any | Details for aftonfalk-1.7.1-py3-none-any.whl |
Total release size: 31.9 kB
Release files / aftonfalk-1.7.1.tar.gz
| Download URL | aftonfalk-1.7.1.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15a35d159aab91fe9a00e0972f59368d9c483bee2d161cf26c44dfea17e9eab3
|
|
BLAKE2b-256 checksum How to use checksums |
dd2fa48ffd717a6f213a4d00d4d36592984b105f7466210a5c38b601d37116f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / aftonfalk-1.7.1-py3-none-any.whl
| Download URL | aftonfalk-1.7.1-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c0b8ed594db4ca7d7d76f6e03c5194e628cfe3443d4a370d276d18f8ad4cc86
|
|
BLAKE2b-256 checksum How to use checksums |
b63ddf8dc4c2223be34f20790a3b6fa58c77513ea02d11e984ef7a1676490c47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for aftonfalk 1.7.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.