Skip to content

Commit

Permalink
Merge pull request #1 from jowilf/update_docs
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
jowilf authored Aug 11, 2022
2 parents 20220a4 + 25671d6 commit 91ca3e0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish on Pypi
name: Publish
on:
release:
types:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python package
name: Test suite

on:
push:
Expand Down Expand Up @@ -93,5 +93,3 @@ jobs:
run: poetry run bash scripts/coverage.sh
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The key features are:

---

**Documentation**: [https://github.com/jowilf/sqlalchemy-file](https://github.com/jowilf/sqlalchemy-file)
**Documentation**: [https://jowilf.github.io/sqlalchemy-file](https://jowilf.github.io/sqlalchemy-file/)

**Source Code**: [https://github.com/jowilf/sqlalchemy-file](https://github.com/jowilf/sqlalchemy-file)

Expand Down
14 changes: 11 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ uploading them to various storage such as Amazon S3, Rackspace CloudFiles, Googl
using [Apache Libcloud](https://github.com/apache/libcloud).

<p align="center">
<a href="https://github.com/jowilf/sqlalchemy-file/actions">
<img src="https://github.com/jowilf/sqlalchemy-file/actions/workflows/test.yml/badge.svg" alt="Test suite">
</a>
<a href="https://github.com/jowilf/sqlalchemy-file/actions">
<img src="https://github.com/jowilf/sqlalchemy-file/actions/workflows/publish.yml/badge.svg" alt="Publish">
</a>
<a href="https://pypi.org/project/sqlalchemy-file/">
<img src="https://badge.fury.io/py/sqlalchemy-file.svg" alt="Package version">
</a>
<a href="https://pypi.org/project/sqlalchemy-file/">
<img src="https://img.shields.io/pypi/pyversions/sqlalchemy-file?color=2334D058" alt="Supported Python versions">
</a>
</p>


Expand All @@ -32,7 +41,7 @@ The key features are:

---

**Documentation**: [https://github.com/jowilf/sqlalchemy-file](https://github.com/jowilf/sqlalchemy-file)
**Documentation**: [https://jowilf.github.io/sqlalchemy-file](https://jowilf.github.io/sqlalchemy-file/)

**Source Code**: [https://github.com/jowilf/sqlalchemy-file](https://github.com/jowilf/sqlalchemy-file)

Expand Down Expand Up @@ -72,8 +81,7 @@ from libcloud.storage.drivers.local import LocalStorageDriver
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session

from sqlalchemy_file import FileField, File
from sqlalchemy_file import File, FileField
from sqlalchemy_file.storage import StorageManager

Base = declarative_base()
Expand Down
39 changes: 39 additions & 0 deletions docs_src/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os

from libcloud.storage.drivers.local import LocalStorageDriver
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session
from sqlalchemy_file import File, FileField
from sqlalchemy_file.storage import StorageManager

Base = declarative_base()


# Define your model
class Attachment(Base):
__tablename__ = "attachment"

id = Column(Integer, autoincrement=True, primary_key=True)
name = Column(String(50), unique=True)
content = Column(FileField)


# Configure Storage
os.makedirs("/tmp/storage/attachment", 0o777, exist_ok=True)
container = LocalStorageDriver("/tmp/storage").get_container("attachment")
StorageManager.add_storage("default", container)

# Save your model
engine = create_engine(
"sqlite:///example.db", connect_args={"check_same_thread": False}
)
Base.metadata.create_all(engine)

with Session(engine) as session:
session.add(Attachment(name="attachment1", content=open("./example.txt", "rb")))
session.add(Attachment(name="attachment2", content=b"Hello world"))
session.add(Attachment(name="attachment3", content="Hello world"))
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")
session.add(Attachment(name="attachment4", content=file))
session.commit()
18 changes: 16 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
site_name: SQLAlchemy File
site_description: SQLAlchemy-file is a SQLAlchemy extension for attaching files to SQLAlchemy model and uploading them to various storage such as Amazon S3, Rackspace CloudFiles, Google Storage and others using Apache Libcloud.
site_url: https://jowilf.github.io/sqlalchemy-file
repo_name: jowilf/sqlalchemy-file
repo_url: https://github.com/jowilf/sqlalchemy-file
theme:
name: material
icon:
repo: fontawesome/solid/file-export
logo: material/file-cloud
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
Expand Down Expand Up @@ -60,4 +64,14 @@ plugins:
show_root_heading: true
show_source: false
watch:
- sqlalchemy_file
- sqlalchemy_file


extra:
social:
- icon: fontawesome/brands/github
link: https://github.com/jowilf
- icon: fontawesome/brands/twitter
link: https://twitter.com/jowilf
- icon: fontawesome/brands/linkedin
link: https://www.linkedin.com/in/jocelin-hounon-2008aa139
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = """SQLAlchemy-file is a SQLAlchemy extension for attaching files
authors = ["Jocelin Hounon <hounonj@gmail.com>"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/jowilf/sqlalchemy-file"
homepage = "https://jowilf.github.io/sqlalchemy-file"
repository = "https://github.com/jowilf/sqlalchemy-file"
classifiers = [
'Development Status :: 4 - Beta',
Expand All @@ -33,7 +33,6 @@ SQLAlchemy = ">=1.4,<1.5.0"
apache-libcloud = "^3.6.0"

[tool.poetry.dev-dependencies]
filedepot = "^0.8.0"
pytest = "^7.1.2"
sqlmodel = "^0.0.6"
Pillow = "^9.2.0"
Expand Down

0 comments on commit 91ca3e0

Please sign in to comment.