OLX database models and migrations
Project description
OLX Database Package
A Python package for OLX database models and migrations.
Installation
pip install olx-db
For development installation:
pip install -e .
Configuration
The package uses environment variables for configuration:
OLX_DB_URL: Database URL (required)OLX_DEFAULT_SENDING_FREQUENCY_MINUTES: Default sending frequency in minutes (default: 60)OLX_DEFAULT_LAST_MINUTES_GETTING: Default last minutes for getting items (default: 30)
You can set these environment variables directly or use a .env file.
Usage
Database Models
from olx_db.db import get_db, MonitoringTask, ItemRecord
# Use the database session
with next(get_db()) as db:
tasks = db.query(MonitoringTask).all()
# ...
Migrations
To create a new migration:
olx-db-makemigrations "migration message"
To apply migrations:
olx-db-migrate
Docker Support
Example docker-compose.yml:
version: '3'
services:
app:
build: .
environment:
- OLX_DB_URL=postgresql://user:password@db:5432/olx
depends_on:
- db
command: olx-db-migrate
db:
image: postgres:13
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=olx
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
Publishing to a Private PyPI Repository
- Update the
.pypircfile with your private repository credentials:
[distutils]
index-servers =
pypi
private-repo
[pypi]
username = __token__
password = your_pypi_token
[private-repo]
repository = https://your-private-repo-url/simple/
username = your_username
password = your_password
- Build the package:
python -m pip install --upgrade build
python -m build
- Upload to your private repository:
python -m pip install --upgrade twine
python -m twine upload --repository private-repo dist/*
Using in Other Projects
Once published to your private repository, you can install it in other projects:
pip install --extra-index-url https://your-private-repo-url/simple/ olx-db
Or add to your requirements.txt:
--extra-index-url https://your-private-repo-url/simple/
olx-db==0.1.0
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 olx_db_wonsky-0.1.0.tar.gz.
File metadata
- Download URL: olx_db_wonsky-0.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e8f5676051a875efaf64cf6ad27442854ad0f3479c70aa0c9a583a6cca4ee50
|
|
| MD5 |
10a3eccdf3439f9489f063de99c5c65a
|
|
| BLAKE2b-256 |
89773ccf66b68b5d1874c15fb388dff6746686b985ee63a8382c122235a797e0
|
File details
Details for the file olx_db_wonsky-0.1.0-py3-none-any.whl.
File metadata
- Download URL: olx_db_wonsky-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07763c6e92a241fe4d2fa4a730dc73e0e372de8208f87da2a8bec59f451e4098
|
|
| MD5 |
fcaaab1598e9a65e12422aa21be1f68c
|
|
| BLAKE2b-256 |
0b853bb4597773f7434c7065a183b1fb32ae2cd2f5828a0bbd3958a6908ab940
|