diff --git a/TornadoYandexMoney/DataBase/Connection.py b/TornadoYandexMoney/DataBase/Connection.py new file mode 100644 index 0000000..3e036ff --- /dev/null +++ b/TornadoYandexMoney/DataBase/Connection.py @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- + +''' +Created on Apr 14, 2017 +@author: bvn13 +''' + +from sqlalchemy import create_engine +from sqlalchemy.orm import scoped_session +from sqlalchemy.orm.session import sessionmaker + +from TornadoYandexMoney.DataBase.Settings import settings + + +engine = create_engine('%s://%s:%s@%s:%s/%s' % ( + settings['protocol'], + settings['user'], + settings['password'], + settings['host'], + settings['port'], + settings['database'])) +session_factory = sessionmaker(bind=engine) +Session = scoped_session(session_factory) + +#Session = sessionmaker(bind=engine) + + +class Connection(object): + + @staticmethod + def getSession(): + return Session() diff --git a/DataBase/DAO/Base.py b/TornadoYandexMoney/DataBase/DAO/Base.py similarity index 100% rename from DataBase/DAO/Base.py rename to TornadoYandexMoney/DataBase/DAO/Base.py diff --git a/TornadoYandexMoney/DataBase/DAO/Payment.py b/TornadoYandexMoney/DataBase/DAO/Payment.py new file mode 100644 index 0000000..803e6d4 --- /dev/null +++ b/TornadoYandexMoney/DataBase/DAO/Payment.py @@ -0,0 +1,30 @@ + +from sqlalchemy import Column, Integer, Numeric, String, Sequence, DateTime, ForeignKey, Boolean + +from TornadoYandexMoney.DataBase.DAO import Base + + + +class Payment(Base) : + + __tablename__ = 'payments' + id = Column(Integer, Sequence('payments_id_seq'), primary_key=True) + user_id = Column(Integer) + cps_email = Column(String) + cps_phone = Column(String) + customer_number = Column(String) + fail_url = Column(String) + invoice_id = Column(Integer) + order_amount = Column(Numeric) + order_currency = Column(Integer) + payer_code = Column(String) + payment_type = Column(String, default='ac') + performed_datetime = Column(DateTime) + pub_date = Column(DateTime) + scid = Column(Integer) + shop_amount = Column(Numeric) + shop_currency = Column(Integer) + shop_id = Column(Integer) + status = Column(String) + success_url = Column(String) + article_id = Column(Integer) diff --git a/DataBase/DAO/__init__.py b/TornadoYandexMoney/DataBase/DAO/__init__.py similarity index 100% rename from DataBase/DAO/__init__.py rename to TornadoYandexMoney/DataBase/DAO/__init__.py diff --git a/TornadoYandexMoney/DataBase/Manager.py b/TornadoYandexMoney/DataBase/Manager.py new file mode 100644 index 0000000..63c8cca --- /dev/null +++ b/TornadoYandexMoney/DataBase/Manager.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- + +''' +Created on Apr 14, 2017 +@author: bvn13 +''' +from abc import ABCMeta, abstractstaticmethod + + +class Manager(metaclass=ABCMeta): + ''' + Database table manager + ''' + pass + + @abstractstaticmethod + def _find_by_id(id : int): + pass + + +Manager.register(tuple) \ No newline at end of file diff --git a/DataBase/Managers/__init__.py b/TornadoYandexMoney/DataBase/Managers/__init__.py similarity index 100% rename from DataBase/Managers/__init__.py rename to TornadoYandexMoney/DataBase/Managers/__init__.py diff --git a/TornadoYandexMoney/DataBase/Settings.py b/TornadoYandexMoney/DataBase/Settings.py new file mode 100644 index 0000000..5269b31 --- /dev/null +++ b/TornadoYandexMoney/DataBase/Settings.py @@ -0,0 +1,17 @@ +# -*- encoding: utf-8 -*- + +''' +Created on Apr 14, 2017 +@author: bvn13 +''' + +settings = { + + 'protocol' : 'postgresql', + 'host' : 'localhost', + 'port' : '5432', + 'database' : 'tornado_ym', + 'user' : 'tornado_ym', + 'password' : 'tornado_ym_pass', + +} \ No newline at end of file diff --git a/DataBase/__init__.py b/TornadoYandexMoney/DataBase/__init__.py similarity index 100% rename from DataBase/__init__.py rename to TornadoYandexMoney/DataBase/__init__.py diff --git a/views/__init__.py b/TornadoYandexMoney/__init__.py similarity index 100% rename from views/__init__.py rename to TornadoYandexMoney/__init__.py diff --git a/DataBase/Manager.py b/TornadoYandexMoney/views/__init__.py similarity index 100% rename from DataBase/Manager.py rename to TornadoYandexMoney/views/__init__.py