-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_only.py
85 lines (73 loc) · 2.54 KB
/
db_only.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
# -*- coding: UTF-8 -*-
# db.py: database schema
from elixir import *
import os, os.path
db_server = 'localhost'
db_user = 'anass'
db_pass = 'anass=1430'
db_name = 'quran'
db_prefix = 'db_'
db_mysql_path = 'mysql://%s:%s@%s/%s' %(db_user, db_pass, db_server, db_name)
db_sqlite_path = "sqlite:///"+os.path.expanduser("~/python-modules/quran_quize/db.db")
metadata.bind = db_sqlite_path
class users(Entity):
using_options(tablename = db_prefix+'users')
fb_id = Field(Unicode(100))
fb_user_name = Field(UnicodeText)
fb_full_name = Field(UnicodeText)
fb_gender = Field(Unicode(10))
fb_locale = Field(Unicode(5))
access_token = Field(UnicodeText)
expires = Field(DateTime)
class rounds(Entity):
using_options(tablename = db_prefix+'rounds')
user = ManyToOne('users')
parts_num = Field(Integer)
is_desc = Field(Integer)
question_num = Field(Integer)
correct_answers = Field(Integer)
wrong_answers = Field(Integer)
points = Field(Integer)
time = Field(DateTime)
is_finished = Field(Integer)
class statistics(Entity):
using_options(tablename = db_prefix+'statistics')
user = ManyToOne('users')
rounds_num = Field(Integer)
questions_num = Field(Integer)
correct_answers = Field(Integer)
wrong_answers = Field(Integer)
points = Field(Integer)
extra_points = Field(Integer)
total_points = Field(Integer)
class invites(Entity):
using_options(tablename = db_prefix+'invites')
user = ManyToOne('users')
fb_request_id = Field(Unicode(100))
fb_friend_id = Field(Unicode(100))
is_finished = Field(Integer)
class Quran(Entity):
using_options(tablename = db_prefix+'quran')
id = Field(Integer, primary_key = True)
othmani = Field(UnicodeText)
imlai = Field(UnicodeText)
class Sajadat(Entity):
using_options(tablename = db_prefix+'sajadat')
id = Field(Integer, primary_key = True)
sura = Field(Integer,index = True, primary_key = True)
aya = Field(Integer)
sajda_type = Field(Integer)
comment = Field(UnicodeText)
class SuraInfo(Entity):
using_options(tablename = db_prefix+'sura_info')
id = Field(Integer, primary_key = True)
sura_name = Field(UnicodeText, primary_key = True)
other_names = Field(UnicodeText)
makki = Field(Integer)
starting_row = Field(Integer)
comment = Field(UnicodeText)
class Tahzeeb(Entity):
using_options(tablename = db_prefix+'tahzeeb')
id = Field(Integer, primary_key = True)
sura = Field(Integer,index = True, primary_key = True)
aya = Field(Integer, primary_key = True)