GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-orm-benchmarks/benchmarks/sqlobject/models.py at dev · objectbox/python-orm-benchmarks Expand file tree/ Copy pathmodels.pyMore file actions 93 lines (80 loc) · 3.08 KB / Copy pathmodels.pyFile metadata and controls93 lines (80 loc) · 3.08 KB 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 import os from datetime import datetime from decimal import Decimal from sqlobject import ( DatabaseIndex, DateTimeCol, DecimalCol, FloatCol, ForeignKey, IntCol, JSONCol, MultipleJoin, RelatedJoin, SQLObject, UnicodeCol, connectionForURI, sqlhub, ) dbtype = os.environ.get("DBTYPE", "") if dbtype == "postgres": conn = sqlhub.processConnection = connectionForURI( f"postgres://postgres:{os.environ.get('PASSWORD')}@localhost:{os.environ.get('PGPORT', '5432')}/tbench" ) elif dbtype == "mysql": conn = sqlhub.processConnection = connectionForURI( f"mysql://root:{os.environ.get('PASSWORD')}@127.0.0.1:{os.environ.get('MYPORT', '3306')}/tbench" ) else: conn = sqlhub.processConnection = connectionForURI("sqlite:/tmp/db.sqlite3") test = int(os.environ.get("TEST", "1")) if test == 1: class Journal(SQLObject): timestamp = DateTimeCol(default=datetime.now, notNone=True) level = IntCol(notNone=True) level_index = DatabaseIndex("level") text = UnicodeCol(length=255, notNone=True) text_index = DatabaseIndex("text") if test == 2: class Journal(SQLObject): timestamp = DateTimeCol(default=datetime.now, notNone=True) level = IntCol(notNone=True) level_index = DatabaseIndex("level") text = UnicodeCol(length=255, notNone=True) text_index = DatabaseIndex("text") parent = ForeignKey("Journal", default=None) children = MultipleJoin("Journal") related = RelatedJoin("Journal", joinColumn="journal_id", otherColumn="journal_from_id") related_from = RelatedJoin( "Journal", joinColumn="journal_from_id", otherColumn="journal_id", createRelatedTable=False, ) if test == 3: class Journal(SQLObject): timestamp = DateTimeCol(default=datetime.now, notNone=True) level = IntCol(notNone=True) level_index = DatabaseIndex("level") text = UnicodeCol(length=255, notNone=True) text_index = DatabaseIndex("text") col_float1 = FloatCol(default=2.2, notNone=True) col_smallint1 = IntCol(default=2, notNone=True) col_int1 = IntCol(default=2000000, notNone=True) col_bigint1 = IntCol(default=99999999, notNone=True) col_char1 = UnicodeCol(length=255, default="value1", notNone=True) col_text1 = UnicodeCol( default="Moo,Foo,Baa,Waa,Moo,Foo,Baa,Waa,Moo,Foo,Baa,Waa", notNone=True ) col_decimal1 = DecimalCol(size=12, precision=8, default=Decimal("2.2"), notNone=True) col_json1 = JSONCol( default={"a": 1, "b": "b", "c": [2], "d": {"e": 3}, "f": True}, notNone=True ) col_float2 = FloatCol(default=None) col_smallint2 = IntCol(default=None) col_int2 = IntCol(default=None) col_bigint2 = IntCol(default=None) col_char2 = UnicodeCol(length=255, default=None) col_text2 = UnicodeCol(default=None) col_decimal2 = DecimalCol(size=12, precision=8, default=None) col_json2 = JSONCol(default=None) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |