| Line 5... |
Line 5... |
| 5 |
'''
|
5 |
'''
|
| 6 |
import datetime
|
6 |
import datetime
|
| 7 |
import elixir
|
7 |
import elixir
|
| 8 |
from elixir.entity import Entity
|
8 |
from elixir.entity import Entity
|
| 9 |
from elixir.fields import Field
|
9 |
from elixir.fields import Field
|
| 10 |
from sqlalchemy.types import Integer, String, DateTime, Float, Boolean
|
10 |
from sqlalchemy.types import Integer, String, DateTime, Float, Boolean, Text
|
| 11 |
from sqlalchemy import create_engine
|
11 |
from sqlalchemy import create_engine
|
| 12 |
from elixir.relationships import OneToMany, ManyToOne, ManyToMany
|
12 |
from elixir.relationships import OneToMany, ManyToOne, ManyToMany
|
| 13 |
from elixir.options import using_options, using_table_options
|
13 |
from elixir.options import using_options, using_table_options
|
| 14 |
from elixir import metadata, setup_all
|
14 |
from elixir import metadata, setup_all
|
| 15 |
|
15 |
|
| Line 214... |
Line 214... |
| 214 |
mrp = Field(Float)
|
214 |
mrp = Field(Float)
|
| 215 |
sellingPrice = Field(Float)
|
215 |
sellingPrice = Field(Float)
|
| 216 |
using_options(shortnames=True)
|
216 |
using_options(shortnames=True)
|
| 217 |
using_table_options(mysql_engine="InnoDB")
|
217 |
using_table_options(mysql_engine="InnoDB")
|
| 218 |
|
218 |
|
| - |
|
219 |
class AuthorizationLog(Entity):
|
| - |
|
220 |
id = Field(Integer, primary_key=True, autoincrement = True)
|
| - |
|
221 |
timestamp = Field(DateTime, default=datetime.datetime.now())
|
| - |
|
222 |
item = ManyToOne('Item')
|
| - |
|
223 |
username = Field(String(30))
|
| - |
|
224 |
reason = Field(Text)
|
| - |
|
225 |
using_options(shortnames=True)
|
| - |
|
226 |
using_table_options(mysql_engine="InnoDB")
|
| - |
|
227 |
|
| 219 |
def initialize(dbname='catalog', db_hostname="localhost"):
|
228 |
def initialize(dbname='catalog', db_hostname="localhost"):
|
| 220 |
#metadata.bind = "sqlite:///inventory-new.sqlite" #need to read it from configserver.
|
229 |
#metadata.bind = "sqlite:///inventory-new.sqlite" #need to read it from configserver.
|
| 221 |
#metadata.bind = 'mysql://root:shop2020@localhost/catalog'
|
230 |
#metadata.bind = 'mysql://root:shop2020@localhost/catalog'
|
| 222 |
engine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200)
|
231 |
engine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200)
|
| 223 |
metadata.bind = engine
|
232 |
metadata.bind = engine
|