| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | 
							- # ============================================================================
 
- # This file is part of Pwman3.
 
- #
 
- # Pwman3 is free software; you can redistribute it and/or modify
 
- # it under the terms of the GNU General Public License, version 2
 
- # as published by the Free Software Foundation;
 
- #
 
- # Pwman3 is distributed in the hope that it will be useful,
 
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
- # GNU General Public License for more details.
 
- #
 
- # You should have received a copy of the GNU General Public License
 
- # along with Pwman3; if not, write to the Free Software
 
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
- # ============================================================================
 
- # Copyright (C) 2012-2015 Oz Nahum <nahumoz@gmail.com>
 
- # ============================================================================
 
- #mysql -u root -p
 
- #create database pwmantest
 
- #create user 'pwman'@'localhost' IDENTIFIED BY '123456';
 
- #grant all on pwmantest.* to 'pwman'@'localhost';
 
- """MySQL Database implementation."""
 
- from __future__ import print_function
 
- from pwman.data.database import Database, __DB_FORMAT__
 
- import MySQLdb as mysql
 
- class MySQLDatabase(Database):
 
-     @classmethod
 
-     def check_db_version(cls, dburi):
 
-         port = 3306
 
-         credentials, host = dburi.netloc.split('@')
 
-         user, passwd = credentials.split(':')
 
-         if ':' in host:
 
-             host, port = host.split(':')
 
-             port = int(port)
 
-         con = mysql.connect(host=host, port=port, user=user, passwd=passwd,
 
-                             db=dburi.path.lstrip('/'))
 
-         cur = con.cursor()
 
-         try:
 
-             cur.execute("SELECT VERSION FROM DBVERSION")
 
-             version = cur.fetchone()
 
-             cur.close()
 
-             con.close()
 
-             return version[-1]
 
-         except mysql.ProgrammingError:
 
-             con.rollback()
 
-     def __init__(self, mysqluri, dbformat=__DB_FORMAT__):
 
-         self._mysqluri = mysqluri
 
-         self.dbversion = dbformat
 
 
  |