Добавлено взамиодействие с базой данных
This commit is contained in:
4
base.py
Normal file
4
base.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
13
main.py
13
main.py
@@ -1,6 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import wx
|
import wx
|
||||||
|
from models import Student, Session
|
||||||
|
|
||||||
|
|
||||||
|
new_session = Session()
|
||||||
class MainFramePanel(wx.Panel):
|
class MainFramePanel(wx.Panel):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(500, 500),
|
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(500, 500),
|
||||||
@@ -100,11 +103,13 @@ class MainFramePanel(wx.Panel):
|
|||||||
self.empty_pole()
|
self.empty_pole()
|
||||||
return
|
return
|
||||||
|
|
||||||
values.append(name)
|
fio = str(familia) + ' ' + str(name)
|
||||||
values.append(familia)
|
|
||||||
values.append(group)
|
student = Student(fname=fio, group=group, zach_number=zach_number)
|
||||||
|
new_session.add(student)
|
||||||
|
new_session.commit()
|
||||||
|
|
||||||
|
|
||||||
print(values)
|
|
||||||
self.frame.Hide()
|
self.frame.Hide()
|
||||||
page2.MainFramePanel.run_page(self)
|
page2.MainFramePanel.run_page(self)
|
||||||
|
|
||||||
|
|||||||
27
models.py
Normal file
27
models.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from sqlalchemy import Column, Integer, String
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
engine = create_engine("sqlite:////odd-perekrestok.db", echo=True)
|
||||||
|
Session = sessionmaker(bind=engine)
|
||||||
|
Base = declarative_base()
|
||||||
|
|
||||||
|
class Student(Base):
|
||||||
|
__tablename__ = 'Student'
|
||||||
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
|
fname = Column("name", String(100))
|
||||||
|
group = Column("group", String(10))
|
||||||
|
zach_number = Column(Integer)
|
||||||
|
|
||||||
|
def __init__(self,fname,group, zach_number):
|
||||||
|
self.fname =fname
|
||||||
|
self.group = group
|
||||||
|
self.zach_number = zach_number
|
||||||
|
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<Student(fname=%s, group=%s, zach_number=%s)" % (self.fname, self.group, self.zach_number)
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Reference in New Issue
Block a user