Dynamic UTF offset.
[philipp/winterrodeln/wrpylib.git] / wrpylib / wrmwdb.py
index b946eb0fc8dd3cf9cce3d6bea7e700297d661a9f..ca2bd1dbb574c80fc994f500fd3756c38fffdefa 100644 (file)
@@ -1,12 +1,15 @@
-#!/usr/bin/python2.7
-# -*- coding: iso-8859-15 -*-
+#!/usr/bin/python3.4
 # $Id$
 # $HeadURL$
 """This module contains code to make tha access of winterrodeln
 tables in MediaWiki easy. The module uses sqlalchemy to access the database.
 """
 from sqlalchemy import Table, Column, types, schema
-from geoalchemy import GeometryExtensionColumn, MultiPolygon
+from sqlalchemy.dialects.mysql import ENUM
+
+
+intermaps_sledrun_id_type = types.Unicode(50)
+intermaps_sledrun_status_type = ENUM('open', 'closed', 'in_preparation', 'unknown')
 
 
 def wrreport_table(metadata):
@@ -51,6 +54,7 @@ def wrsledruncache_table(metadata):
     return Table("wrsledruncache", metadata,
     Column("page_id", types.Integer, schema.ForeignKey('wrreportcache.page_id'), primary_key=True),
     Column("page_title", types.Unicode(255)),
+    Column("name_url", types.Unicode(255)),
     Column("position_latitude", types.Float),
     Column("position_longitude", types.Float),
     Column("top_latitude", types.Float),
@@ -145,7 +149,7 @@ def wrregion_table(metadata):
     Column("id", types.Integer, primary_key=True),
     Column("name", types.Unicode(50)),
     Column("page_id", types.Integer),
-    GeometryExtensionColumn("border", MultiPolygon(2, 4326))
+    Column("border", types.LargeBinary) # MultiPolygon(2, 4326)
     )
 
 
@@ -157,7 +161,54 @@ def wrregioncache_table(metadata):
     """
     return Table("wrregioncache", metadata,
     Column("id", types.Integer, primary_key=True),
-    Column("wrregion_id", types.Integer, schema.ForeignKey('wrregin.id')),
+    Column("region_id", types.Integer, schema.ForeignKey('wrregin.id')),
     Column("page_id", types.Integer)
     )
 
+
+def wrintermapssledrun_table(metadata):
+    """Returns the sqlalchemy table representing the "wrintermapssledrun" Winterrodeln table in MediaWiki.
+    Current table definition.
+    * version 1.5 (introduction)
+    :param metadata: metadata = sqlalchemy.MetaData()
+    """
+    return Table("wrintermapssledrun", metadata,
+        Column("intermaps_sledrun_id", intermaps_sledrun_id_type, primary_key=True),
+        Column("intermaps_sledrun_name", types.Unicode(255)),
+        Column("intermaps_region_id", types.Integer),
+        Column("intermaps_region_name", types.Unicode(255)),
+        Column("intermaps_country", types.Unicode(10)),
+        Column("wr_page_id", types.Integer, schema.ForeignKey("page.page_id")),
+        Column("wr_page_title", types.Unicode(255)),
+        Column("show_status", types.Boolean, nullable=False)
+    )
+
+
+def wrintermapsreport_table(metadata):
+    """Returns the sqlalchemy table representing the "wrintermapsreport" Winterrodeln table in MediaWiki.
+    Current table definition.
+    * version 1.5 (introduction)
+    :param metadata: metadata = sqlalchemy.MetaData()
+    """
+    return Table("wrintermapsreport", metadata,
+        Column("intermaps_sledrun_id", intermaps_sledrun_id_type, primary_key=True),
+        Column("status", intermaps_sledrun_status_type, nullable=False),
+        Column("last_update", types.DateTime, nullable=False),
+        Column("last_check", types.DateTime, nullable=False),
+        Column("utc_offset", types.Integer, nullable=False)
+    )
+
+
+def wrintermapsreporthistory_table(metadata):
+    """Returns the sqlalchemy table representing the "wrintermapsreporthistory" Winterrodeln table in MediaWiki.
+    Current table definition.
+    * version 1.5 (introduction)
+    :param metadata: metadata = sqlalchemy.MetaData()
+    """
+    return Table("wrintermapsreporthistory", metadata,
+        Column("id", types.Integer, primary_key=True),
+        Column("intermaps_sledrun_id", intermaps_sledrun_id_type, nullable=False),
+        Column("status", intermaps_sledrun_status_type, nullable=False),
+        Column("last_update", types.DateTime, nullable=False),
+        Column("utc_offset", types.Integer, nullable=False)
+    )