Пример #1
0
def InsertDB(pmodel):

    Session = sessionmaker(bind=ConnectMySQL())
    sessiondb = Session()
    users = pmodel
    sessiondb.add(users)
    sessiondb.commit()
    sessiondb.close()
Пример #2
0
def Edit(pModel):

    Session = sessionmaker(bind=ConnectMySQL())
    sessiondb = Session()
    editusers = pModel
    sessiondb.merge(editusers)
    sessiondb.commit()
    sessiondb.close()
    def SelectAll(self):

        Session = sessionmaker(bind=ConnectMySQL())
        self.sessiondb = Session()
        self.serialized_labels = [
            serialize_sqlalchemy().serialize(label)
            for label in self.sessiondb.query(django_sqlA).all()
        ]
        self.my_json = dumps(self.serialized_labels)
        return self.my_json
Пример #4
0
def Delete(pModel=django_sqlA(), pID=5):

    Session = sessionmaker(bind=ConnectMySQL())
    sessiondb = Session()
    q = text("DELETE FROM :model12 WHERE id=:pidd")
    our_user = sessiondb.execute(q, {
        'model12': pModel.__tablename__,
        'pidd': pID
    })
    sessiondb.commit()
    sessiondb.close()
Пример #5
0
def Transaction():

    Session = sessionmaker(bind=ConnectMySQL(), autocommit=True)
    sessiondb = Session()
    trans = sessiondb.begin()
    try:
        ed_user = django_sqlA(name="ramin", fullname="fara", password=1234345)
        sessiondb.add(ed_user)
        df = django_sqlA(name="love", fullnam1e="hehehooo", password=1234345)
        sessiondb.add(df)
        trans.commit()

    except:
        trans.rollback()
        raise
Пример #6
0
from sqlalchemy.ext.declarative import declarative_base

from sqlalchemy import Column, Integer, Binary

### Define Image for store DB (BLOB)

Base = declarative_base()


class Image(Base):

    __tablename__ = 'img'
    ID = Column(Integer, primary_key=True)
    image = Column(Binary(1000000))  #default size 64KB Now 314KB defined


from config.dbconfig import CONNECTOR
if CONNECTOR:
    from db.ConnectorDB import ConnectMySQL
    Base.metadata.create_all(ConnectMySQL().engine)
Пример #7
0
def SelectAll(student):

    Session = sessionmaker(bind=ConnectMySQL())
    sessiondb = Session()
    lst = sessiondb.query(student).all()
    return lst