Skip to content

Commit

Permalink
Merge pull request #47 from Martlark/2.1.1
Browse files Browse the repository at this point in the history
2.1.1 fix json with sqlite - add some testing begininings for Dockerfile
  • Loading branch information
Martlark authored Sep 4, 2022
2 parents b5bde00 + b419033 commit 6d5ff12
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_KEY }}
run: |
python setup.py sdist bdist_wheel
twine check dist/*
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# include file
include VERSION

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ Version 2.0.1 changes most of the properties, hooks and methods to use a more no

## Release Notes

- 2.1.1 - Improve sqlite JSON handling
- 2.1.0 - Convert readme to markdown. Add support for JSON columns. Withdraw Python 3.6 Support. Use unittest instead of pytest. NOTE: Changes `__fs_convert_types__` to a `dict`.
- 2.0.3 - Allow more use of model column variables instead of "quoted" field names. Fix missing import for FlaskSerialize.
- 2.0.2 - Fix table formatting.
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.1
17 changes: 9 additions & 8 deletions flask_serialize/flask_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FlaskSerializeMixin:
# previous values of an instance before update attempted
__fs_previous_field_value__ = {}
# current version
__fs_version__ = "2.1.0"
__fs_version__ = "2.1.1"

@staticmethod
def __fs_json_converter__(value):
Expand Down Expand Up @@ -341,23 +341,24 @@ def __fs_sqlite_from_str_json_converter(value):
return value

@staticmethod
def __fs_sqlite_to_str_json_converter(value):
def __fs_sqlite_to_dict_json_converter(value):
"""
convert a sqlite json string from a type that can be json
to a string. if already a string then leave be
to a dict. if a string do loads
:param value: string to convert
:return: decoded string
"""
if value in ["", None]:
return "{}"
return {}

if type(value) == str:
return value
return json.loads(value)

if type(value) in FlaskSerializeMixin.__fs_json_types:
value = json.dumps(value)
return value
return value

return {"value": str(value)}

@staticmethod
def __fs_sqlite_to_date_converter(value):
Expand Down Expand Up @@ -418,7 +419,7 @@ def _fs_get_props(self):
] = self.__fs_sqlite_to_date_converter
self.__fs_convert_types__[
str(dict)
] = self.__fs_sqlite_to_str_json_converter
] = self.__fs_sqlite_to_dict_json_converter
props.converters["JSON"] = self.__fs_sqlite_from_str_json_converter

for o, v in self.__fs_convert_types_original__.items():
Expand Down
6 changes: 4 additions & 2 deletions pypar.commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ pip install pytest-flask

# on each release

VERSION=$(cat VERSION)

. venv3/bin/activate
python setup.py sdist bdist_wheel
twine check dist/flask_serialize-2.1.0*
twine upload dist/flask_serialize-2.1.0* -u martlark
twine check dist/flask_serialize-${VERSION}*
twine upload dist/flask_serialize-${VERSION}* -u __token__
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from setuptools import setup


VERSION = "2.1.0"
VERSION = open("VERSION", "r", encoding="utf-8").read()
LONG_DESCRIPTION = open("README.md", "r", encoding="utf-8").read()

setup(
Expand All @@ -40,10 +40,10 @@
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Operating System :: POSIX",
"Operating System :: MacOS",
"Operating System :: Unix",
Expand Down
23 changes: 23 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.10
# runs from this dir
WORKDIR /app
# upgrade pip
RUN pip install -U pip

# mssql driver install
COPY ./test/install-mssql-17-driver.sh /tmp
RUN bash /tmp/install-mssql-17-driver.sh

# engines
COPY ./test/engine_requirements.txt /tmp
RUN pip install -r /tmp/engine_requirements.txt

# copy over our app code
COPY . /app

RUN mkdir -p /persist
RUN apt-get update

# start server

ENTRYPOINT [ "bash", "resources/entrypoint.sh" ]
11 changes: 11 additions & 0 deletions test/engine_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# engines for connecting
# postgres
psycopg2==2.9.2
# mssql
pyodbc
# mysql
PyMySQL
cryptography
# dynamo db
boto3

19 changes: 19 additions & 0 deletions test/install-mssql-17-driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#Debian 10
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list


apt-get update
ACCEPT_EULA=Y apt-get install -y msodbcsql17
# optional: for bcp and sqlcmd
ACCEPT_EULA=Y apt-get install -y mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
#apt-get install -y unixodbc-dev
# optional: kerberos library for debian-slim distributions
#apt-get install -y libgssapi-krb5-2

0 comments on commit 6d5ff12

Please sign in to comment.