In progress: Jeeves communication is now based on SQLAlchemy
This commit is contained in:
parent
0fdc029153
commit
28726fee01
21 changed files with 637 additions and 78 deletions
44
pyjeeves/repositories/article.py
Normal file
44
pyjeeves/repositories/article.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from pyjeeves.models.raw import Articles
|
||||
from sqlalchemy.sql.expression import and_
|
||||
|
||||
from pyjeeves import logging
|
||||
logger = logging.getLogger("PyJeeves." + __name__)
|
||||
|
||||
|
||||
# Relocate Jeeves modules to separate folder and let a "master" module handle imports, and setup.
|
||||
class Article():
|
||||
"""Handles dispatch locations in Jeeves"""
|
||||
def __init__(self):
|
||||
super(Article, self).__init__()
|
||||
|
||||
@staticmethod
|
||||
def get(art_no):
|
||||
""" Query an article by number """
|
||||
return Articles.query.filter_by(
|
||||
ArtNr=art_no
|
||||
).one()
|
||||
|
||||
@staticmethod
|
||||
def get_all(filter_=and_(Articles.ItemStatusCode == 0, Articles.ArtKod != 2)):
|
||||
# .filter_by(ItemStatusCode=0, ArtKod=2)
|
||||
return Articles.query.filter(filter_).all()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print([column.key for column in Companies.__table__.columns])
|
||||
|
||||
logger.info("Starting TEST")
|
||||
# session = RawSession()
|
||||
|
||||
logger.info("Testing gettings an article")
|
||||
# c1 = session.query(Companies).filter_by(FtgNr="179580").first()
|
||||
# print(Articles)
|
||||
c1 = Articles.query.filter_by(ArtNr="2103").first()
|
||||
print(c1)
|
||||
logger.info(c1.json)
|
||||
|
||||
print (
|
||||
len(Article.get_all())
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue