SQLAlchemy model Payment
parent
0714df66ca
commit
5f4bd4aa72
|
@ -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()
|
|
@ -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)
|
|
@ -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)
|
|
@ -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',
|
||||
|
||||
}
|
Loading…
Reference in New Issue