from sqlalchemy import create_engine
from sqlalchemy_utils import functions
from sqlalchemy.orm import sessionmaker

class Connection:
	def __init__(self, db, name, password, ip, port):
		if db == "postgresql":
			connection = "postgresql+psycopg2://" + name + ":" + password + "@" + ip + ":" + port			
		elif db == "mysql":
			connection = "mysql+pymysql://" + name + ":" + password + "@" + ip + ":" + port
		
		db_name = 'wikilink'
		# Turn off echo
		engine = create_engine(connection + "/" + db_name + '?charset=utf8', echo=False, encoding='utf-8')
		if not functions.database_exists(engine.url):
			functions.create_database(engine.url)

		self.session = sessionmaker(bind=engine)()
		# If table don't exist, Create.
		if (not engine.dialect.has_table(engine, 'link') and not engine.dialect.has_table(engine, 'page')):
			Base.metadata.create_all(engine)
Change class name to Connection
Change class name to Connection

Signed-off-by: Tran Ly Vu <0555cc0f3d5a46ac8c0e84ddf31443494c66bd55@gmail.com>
