-#!/usr/bin/python2.7
-# -*- coding: iso-8859-15 -*-
-import types
+#!/usr/bin/python3.4
from sqlalchemy import schema
from sqlalchemy.engine import create_engine
from sqlalchemy.sql import select
def connect():
engine = create_engine('mysql://philipp@localhost:3306/philipp_winterrodeln_wiki?charset=utf8&use_unicode=1')
- # engine = create_engine('mysql://philipp@localhost:3306/philipp_winterrodeln_wiki?charset=utf8&use_unicode=0')
connection = engine.connect()
- transaction = connection.begin()
+ connection.begin()
return connection
metadata = schema.MetaData()
tpage = mwdb.page_table(metadata)
page = connect().execute(select([tpage], tpage.c.page_id == 1321)).first()
- assert type(page.page_title) == types.UnicodeType
- assert type(page.page_restrictions) == types.StringType
- assert type(page.page_touched) == types.UnicodeType
-
+ assert type(page.page_title) == str
+ assert type(page.page_restrictions) == bytes
+ assert type(page.page_touched) == str
def test_datatype_revision(self):
metadata = schema.MetaData()
trevision = mwdb.revision_table(metadata)
revision = connect().execute(select([trevision], trevision.c.rev_id == 7586)).first()
- assert type(revision.rev_comment) == types.UnicodeType
- assert type(revision.rev_user_text) == types.UnicodeType
- assert type(revision.rev_timestamp) == types.UnicodeType
-
+ assert type(revision.rev_comment) == str
+ assert type(revision.rev_user_text) == str
+ assert type(revision.rev_timestamp) == str
def test_datatypes_text(self):
metadata = schema.MetaData()
ttext = mwdb.text_table(metadata)
text = connect().execute(select([ttext], ttext.c.old_id==7438)).first()
- assert type(text.old_text) == types.UnicodeType
- assert type(text.old_flags) == types.UnicodeType
- assert text.old_flags == u'utf-8'
-
+ assert type(text.old_text) == str
+ assert type(text.old_flags) == str
+ assert text.old_flags == 'utf-8'
def test_datatype_user(self):
metadata = schema.MetaData()
tuser = mwdb.user_table(metadata)
user = connect().execute(select([tuser], tuser.c.user_id == 1)).first()
- assert type(user.user_name) == types.UnicodeType
- assert type(user.user_real_name) == types.UnicodeType
- assert type(user.user_email) == types.UnicodeType
- assert user.user_name == u'Philipp'
-
+ assert type(user.user_name) == str
+ assert type(user.user_real_name) == str
+ assert type(user.user_email) == str
+ assert user.user_name == 'Philipp'
def test_datatype_categorylinks(self):
metadata = schema.MetaData()
tcategorylinks = mwdb.categorylinks_table(metadata)
categorylinks = connect().execute(select([tcategorylinks], tcategorylinks.c.cl_from == 609)).first()
- assert type(categorylinks.cl_to) == types.UnicodeType
- assert type(categorylinks.cl_sortkey) == types.UnicodeType
- assert categorylinks.cl_sortkey == u'ALT BÄRNBAD'
-
+ assert type(categorylinks.cl_to) == str
+ assert type(categorylinks.cl_sortkey) == str
+ assert categorylinks.cl_sortkey == 'ALT BÄRNBAD'