Skip to content

Commit 91ca3e0

Browse files
authored
Merge pull request #1 from jowilf/update_docs
Update docs
2 parents 20220a4 + 25671d6 commit 91ca3e0

File tree

7 files changed

+70
-12
lines changed

7 files changed

+70
-12
lines changed

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish on Pypi
1+
name: Publish
22
on:
33
release:
44
types:

.github/workflows/test.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python package
1+
name: Test suite
22

33
on:
44
push:
@@ -93,5 +93,3 @@ jobs:
9393
run: poetry run bash scripts/coverage.sh
9494
- name: Upload coverage
9595
uses: codecov/codecov-action@v3
96-
with:
97-
token: ${{ secrets.CODECOV_TOKEN }}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The key features are:
3333

3434
---
3535

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

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

docs/index.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ uploading them to various storage such as Amazon S3, Rackspace CloudFiles, Googl
55
using [Apache Libcloud](https://github.com/apache/libcloud).
66

77
<p align="center">
8+
<a href="https://github.com/jowilf/sqlalchemy-file/actions">
9+
<img src="https://github.com/jowilf/sqlalchemy-file/actions/workflows/test.yml/badge.svg" alt="Test suite">
10+
</a>
11+
<a href="https://github.com/jowilf/sqlalchemy-file/actions">
12+
<img src="https://github.com/jowilf/sqlalchemy-file/actions/workflows/publish.yml/badge.svg" alt="Publish">
13+
</a>
814
<a href="https://pypi.org/project/sqlalchemy-file/">
915
<img src="https://badge.fury.io/py/sqlalchemy-file.svg" alt="Package version">
1016
</a>
17+
<a href="https://pypi.org/project/sqlalchemy-file/">
18+
<img src="https://img.shields.io/pypi/pyversions/sqlalchemy-file?color=2334D058" alt="Supported Python versions">
19+
</a>
1120
</p>
1221

1322

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

3342
---
3443

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

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

@@ -72,8 +81,7 @@ from libcloud.storage.drivers.local import LocalStorageDriver
7281
from sqlalchemy import Column, Integer, String, create_engine
7382
from sqlalchemy.ext.declarative import declarative_base
7483
from sqlalchemy.orm import Session
75-
76-
from sqlalchemy_file import FileField, File
84+
from sqlalchemy_file import File, FileField
7785
from sqlalchemy_file.storage import StorageManager
7886

7987
Base = declarative_base()

docs_src/example.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import os
2+
3+
from libcloud.storage.drivers.local import LocalStorageDriver
4+
from sqlalchemy import Column, Integer, String, create_engine
5+
from sqlalchemy.ext.declarative import declarative_base
6+
from sqlalchemy.orm import Session
7+
from sqlalchemy_file import File, FileField
8+
from sqlalchemy_file.storage import StorageManager
9+
10+
Base = declarative_base()
11+
12+
13+
# Define your model
14+
class Attachment(Base):
15+
__tablename__ = "attachment"
16+
17+
id = Column(Integer, autoincrement=True, primary_key=True)
18+
name = Column(String(50), unique=True)
19+
content = Column(FileField)
20+
21+
22+
# Configure Storage
23+
os.makedirs("/tmp/storage/attachment", 0o777, exist_ok=True)
24+
container = LocalStorageDriver("/tmp/storage").get_container("attachment")
25+
StorageManager.add_storage("default", container)
26+
27+
# Save your model
28+
engine = create_engine(
29+
"sqlite:///example.db", connect_args={"check_same_thread": False}
30+
)
31+
Base.metadata.create_all(engine)
32+
33+
with Session(engine) as session:
34+
session.add(Attachment(name="attachment1", content=open("./example.txt", "rb")))
35+
session.add(Attachment(name="attachment2", content=b"Hello world"))
36+
session.add(Attachment(name="attachment3", content="Hello world"))
37+
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")
38+
session.add(Attachment(name="attachment4", content=file))
39+
session.commit()

mkdocs.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
site_name: SQLAlchemy File
2+
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.
3+
site_url: https://jowilf.github.io/sqlalchemy-file
4+
repo_name: jowilf/sqlalchemy-file
5+
repo_url: https://github.com/jowilf/sqlalchemy-file
26
theme:
37
name: material
48
icon:
5-
repo: fontawesome/solid/file-export
9+
logo: material/file-cloud
610
palette:
711
- media: "(prefers-color-scheme: light)"
812
scheme: default
@@ -60,4 +64,14 @@ plugins:
6064
show_root_heading: true
6165
show_source: false
6266
watch:
63-
- sqlalchemy_file
67+
- sqlalchemy_file
68+
69+
70+
extra:
71+
social:
72+
- icon: fontawesome/brands/github
73+
link: https://github.com/jowilf
74+
- icon: fontawesome/brands/twitter
75+
link: https://twitter.com/jowilf
76+
- icon: fontawesome/brands/linkedin
77+
link: https://www.linkedin.com/in/jocelin-hounon-2008aa139

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description = """SQLAlchemy-file is a SQLAlchemy extension for attaching files
77
authors = ["Jocelin Hounon <hounonj@gmail.com>"]
88
license = "MIT"
99
readme = "README.md"
10-
homepage = "https://github.com/jowilf/sqlalchemy-file"
10+
homepage = "https://jowilf.github.io/sqlalchemy-file"
1111
repository = "https://github.com/jowilf/sqlalchemy-file"
1212
classifiers = [
1313
'Development Status :: 4 - Beta',
@@ -33,7 +33,6 @@ SQLAlchemy = ">=1.4,<1.5.0"
3333
apache-libcloud = "^3.6.0"
3434

3535
[tool.poetry.dev-dependencies]
36-
filedepot = "^0.8.0"
3736
pytest = "^7.1.2"
3837
sqlmodel = "^0.0.6"
3938
Pillow = "^9.2.0"

0 commit comments

Comments
 (0)