-
Notifications
You must be signed in to change notification settings - Fork 0
/
accounting_personnelDB.py
108 lines (79 loc) · 3.29 KB
/
accounting_personnelDB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import relationship
from flask import Flask, render_template, request, redirect, url_for, session, json
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
app = Flask(__name__)
app.config.from_pyfile('config.cfg')
db = SQLAlchemy(app)
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
class User(db.Model):
__tablename__ = 'user'
id = db.Column(db.Integer, primary_key=True)
login = db.Column(db.String(80), unique=True)
password = db.Column(db.String(80), unique=True)
def __init__(self, login, password):
self.login = login
self.password = password
def __repr__(self):
return '<User %r>' % self.login
class Subdivision(db.Model):
__tablename__ = 'subdivision'
id = db.Column(db.INTEGER, primary_key=True)
name = db.Column(db.String(45), unique=True)
cypher = db.Column(db.String(45), unique=True)
departments = db.relationship('Department', backref='department', lazy='dynamic')
def __init__(self,name,cypher):
self.name = name
self.cypher = cypher
class Department(db.Model):
__tablename__ = 'department'
id = db.Column(db.INTEGER, primary_key=True)
name = db.Column(db.String(45), unique=True)
subdivision_id = db.Column(db.INTEGER, db.ForeignKey('subdivision.id'))
worksheets = db.relationship('Worksheet', backref='worksheet1', lazy='dynamic')
def __init__(self,name,subdivision_id):
self.name = name
self.subdivision_id = subdivision_id
def __repr__(self):
return self.name
class Position(db.Model):
__tablename__ = 'position'
id = db.Column(db.INTEGER, primary_key=True)
name = db.Column(db.String(45), unique=True)
salary = db.Column(db.INTEGER)
worksheets = db.relationship('Worksheet', backref='worksheet2', lazy='dynamic')
def __init__(self,name,salary):
self.name = name
self.salary = salary
class Worksheet(db.Model):
__tablename__= 'worksheet'
id = db.Column(db.INTEGER, primary_key=True)
name = db.Column(db.String(45))
department_id = db.Column(db.INTEGER, db.ForeignKey('department.id'))
receipt_date = db.Column(db.Date)
position_id = db.Column(db.INTEGER, db.ForeignKey('position.id'))
academic_title = db.Column(db.String(45))
year_of_birth = db.Column(db.Date)
date_of_dismissal = db.Column(db.Date)
address = db.Column(db.String(45))
telephone = db.Column(db.String(45))
previous_employment = db.Column(db.String(45))
diploma_number = db.Column(db.String(45))
def __init__(self,name,department_id,receipt_date,position_id,academic_title,year_of_birth,date_of_dismissal,address,telephone,previous_employment,diploma_number):
self.name = name
self.department_id = department_id
self.receipt_date = receipt_date
self.position_id = position_id
self.academic_title = academic_title
self.year_of_birth = year_of_birth
self.date_of_dismissal = date_of_dismissal
self.address = address
self.telephone = telephone
self.previous_employment = previous_employment
self.diploma_number = diploma_number
if __name__ == '__main__':
manager.run()