Skip to content

Commit a4f45e3

Browse files
authored
Merge pull request #117 from jowilf/release/0.6.0
Release 0.6.0
2 parents 13f4f58 + ab7745f commit a4f45e3

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,25 @@ engine = create_engine(
112112
Base.metadata.create_all(engine)
113113

114114
with Session(engine) as session, open("./example.txt", "rb") as local_file:
115+
# from an opened local file
115116
session.add(Attachment(name="attachment1", content=local_file))
117+
118+
# from bytes
116119
session.add(Attachment(name="attachment2", content=b"Hello world"))
120+
121+
# from string
117122
session.add(Attachment(name="attachment3", content="Hello world"))
123+
124+
# from a File object with custom filename and content_type
118125
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")
119126
session.add(Attachment(name="attachment4", content=file))
127+
128+
# from a File object specifying a content path
129+
session.add(Attachment(name="attachment5", content=File(content_path="./example.txt")))
130+
120131
session.commit()
121132

133+
122134
```
123135

124136
## Related projects and inspirations

docs/changelog.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.6.0] - 2023-10-07
8+
9+
---
10+
11+
### Added
12+
13+
* Add option to upload files by path in [#87](https://github.com/jowilf/sqlalchemy-file/pull/87)
14+
by [@adscib](https://github.com/adscib)
15+
716
## [0.5.0] - 2023-07-21
817

918
---

docs/index.md

+11
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,22 @@ engine = create_engine(
111111
Base.metadata.create_all(engine)
112112

113113
with Session(engine) as session, open("./example.txt", "rb") as local_file:
114+
# from an opened local file
114115
session.add(Attachment(name="attachment1", content=local_file))
116+
117+
# from bytes
115118
session.add(Attachment(name="attachment2", content=b"Hello world"))
119+
120+
# from string
116121
session.add(Attachment(name="attachment3", content="Hello world"))
122+
123+
# from a File object with custom filename and content_type
117124
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")
118125
session.add(Attachment(name="attachment4", content=file))
126+
127+
# from a File object specifying a content path
128+
session.add(Attachment(name="attachment5", content=File(content_path="./example.txt")))
129+
119130
session.commit()
120131

121132
```

docs_src/example.py

+13
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,22 @@ class Attachment(Base):
3131
Base.metadata.create_all(engine)
3232

3333
with Session(engine) as session, open("./example.txt", "rb") as local_file:
34+
# from an opened local file
3435
session.add(Attachment(name="attachment1", content=local_file))
36+
37+
# from bytes
3538
session.add(Attachment(name="attachment2", content=b"Hello world"))
39+
40+
# from string
3641
session.add(Attachment(name="attachment3", content="Hello world"))
42+
43+
# from a File object with custom filename and content_type
3744
file = File(content="Hello World", filename="hello.txt", content_type="text/plain")
3845
session.add(Attachment(name="attachment4", content=file))
46+
47+
# from a File object specifying a content path
48+
session.add(
49+
Attachment(name="attachment5", content=File(content_path="./example.txt"))
50+
)
51+
3952
session.commit()

sqlalchemy_file/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.5.0"
1+
__version__ = "0.6.0"
22

33
from .file import File as File # noqa
44
from .types import FileField as FileField # noqa

0 commit comments

Comments
 (0)