Python pymysql.ProgrammingError() Examples
The following are 28
code examples of pymysql.ProgrammingError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pymysql
, or try the search function
.
Example #1
Source File: mysql.py From zbxdb with GNU General Public License v3.0 | 6 votes |
def current_role(conn, info): """return current role of database needs to be improved, I have no standby config""" _c = conn.cursor() _c_role = "" try: _c.execute( "select count(*) from performance_schema.replication_applier_status") _data = _c.fetchone() if _data[0] > 0: _c_role = "slave" except pymysql.ProgrammingError: # a bit dirty ... assume primary replication_applier_status is pretty new pass _c.close() _c_role = "primary" return _c_role
Example #2
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def setup_class(cls): pymysql = pytest.importorskip('pymysql') pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') try: pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: raise RuntimeError( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf.") except pymysql.Error: raise RuntimeError( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf.")
Example #3
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def setup_method(self, request, datapath): pymysql = pytest.importorskip('pymysql') pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') try: pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: raise RuntimeError( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf.") except pymysql.Error: raise RuntimeError( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf.") self.method = request.function
Example #4
Source File: pipelines.py From news-please with Apache License 2.0 | 6 votes |
def process_item(self, item, spider): if spider.name in ['RssCrawler', 'GdeltCrawler']: # Search the CurrentVersion table for a version of the article try: self.cursor.execute(self.compare_versions, (item['url'],)) except (pymysql.err.OperationalError, pymysql.ProgrammingError, pymysql.InternalError, pymysql.IntegrityError, TypeError) as error: self.log.error("Something went wrong in rss query: %s", error) # Save the result of the query. Must be done before the add, # otherwise the result will be overwritten in the buffer old_version = self.cursor.fetchone() if old_version is not None and (datetime.datetime.strptime( item['download_date'], "%y-%m-%d %H:%M:%S") - old_version[3]) \ < datetime.timedelta(hours=self.delta_time): # Compare the two download dates. index 3 of old_version # corresponds to the download_date attribute in the DB raise DropItem("Article in DB too recent. Not saving.") return item
Example #5
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def setup_method(self, request, datapath): _skip_if_no_pymysql() import pymysql try: # Try Travis defaults. # No real user should allow root access with a blank password. self.conn = pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') except: pass else: return try: self.conn = pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: pytest.skip( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") except pymysql.Error: pytest.skip( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") self.method = request.function
Example #6
Source File: getmessages_mariadb.py From InsightAgent with Apache License 2.0 | 5 votes |
def query_messages_mariadb(cursor, sql_str): try: logger.info('Starting execute SQL') logger.info(sql_str) # execute sql string cursor.execute(sql_str) parse_messages_mariadb(cursor) except ProgrammingError as e: logger.error(e) logger.error('SQL execute error: '.format(sql_str))
Example #7
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def setup_class(cls): _skip_if_no_pymysql() # test connection import pymysql try: # Try Travis defaults. # No real user should allow root access with a blank password. pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') except: pass else: return try: pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: pytest.skip( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") except pymysql.Error: pytest.skip( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ")
Example #8
Source File: connector.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def execute(self, query): retVal = False try: self.cursor.execute(query) retVal = True except (pymysql.OperationalError, pymysql.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(msg))
Example #9
Source File: connector.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def fetchall(self): try: return self.cursor.fetchall() except pymysql.ProgrammingError, msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(msg)) return None
Example #10
Source File: connector.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def connect(self): self.initConnection() try: self.connector = pymysql.connect(host=self.hostname, user=self.user, passwd=self.password, db=self.db, port=self.port, connect_timeout=conf.timeout, use_unicode=True) except (pymysql.OperationalError, pymysql.InternalError, pymysql.ProgrammingError, struct.error), msg: raise SqlmapConnectionException(getSafeExString(msg))
Example #11
Source File: __main__.py From news-please with Apache License 2.0 | 5 votes |
def reset_mysql(self): """ Resets the MySQL database. """ confirm = self.no_confirm print(""" Cleanup MySQL database: This will truncate all tables and reset the whole database. """) if not confirm: confirm = 'yes' in builtins.input( """ Do you really want to do this? Write 'yes' to confirm: {yes}""" .format(yes='yes' if confirm else '')) if not confirm: print("Did not type yes. Thus aborting.") return print("Resetting database...") try: # initialize DB connection self.conn = pymysql.connect(host=self.mysql["host"], port=self.mysql["port"], db=self.mysql["db"], user=self.mysql["username"], passwd=self.mysql["password"]) self.cursor = self.conn.cursor() self.cursor.execute("TRUNCATE TABLE CurrentVersions") self.cursor.execute("TRUNCATE TABLE ArchiveVersions") self.conn.close() except (pymysql.err.OperationalError, pymysql.ProgrammingError, pymysql.InternalError, pymysql.IntegrityError, TypeError) as error: self.log.error("Database reset error: %s", error)
Example #12
Source File: mysql.py From terracotta with MIT License | 5 votes |
def convert_exceptions(msg: str) -> Iterator: """Convert internal mysql exceptions to our InvalidDatabaseError""" from pymysql import OperationalError, InternalError, ProgrammingError try: yield except (OperationalError, InternalError, ProgrammingError) as exc: raise exceptions.InvalidDatabaseError(msg) from exc
Example #13
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def setup_method(self, method): _skip_if_no_pymysql() import pymysql try: # Try Travis defaults. # No real user should allow root access with a blank password. self.conn = pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') except: pass else: return try: self.conn = pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: pytest.skip( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") except pymysql.Error: pytest.skip( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") self.method = method
Example #14
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def setup_class(cls): _skip_if_no_pymysql() # test connection import pymysql try: # Try Travis defaults. # No real user should allow root access with a blank password. pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') except: pass else: return try: pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: pytest.skip( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") except pymysql.Error: pytest.skip( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ")
Example #15
Source File: connector.py From POC-EXP with GNU General Public License v3.0 | 5 votes |
def execute(self, query): retVal = False try: self.cursor.execute(query) retVal = True except (pymysql.OperationalError, pymysql.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1])
Example #16
Source File: connector.py From POC-EXP with GNU General Public License v3.0 | 5 votes |
def fetchall(self): try: return self.cursor.fetchall() except pymysql.ProgrammingError, msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None
Example #17
Source File: test_nextset.py From scalyr-agent-2 with Apache License 2.0 | 5 votes |
def test_nextset_error(self): con = self.connect(client_flag=CLIENT.MULTI_STATEMENTS) cur = con.cursor() for i in range(3): cur.execute("SELECT %s; xyzzy;", (i,)) self.assertEqual([(i,)], list(cur)) with self.assertRaises(pymysql.ProgrammingError): cur.nextset() self.assertEqual((), cur.fetchall())
Example #18
Source File: connector.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def execute(self, query): retVal = False try: self.cursor.execute(query) retVal = True except (pymysql.OperationalError, pymysql.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1])
Example #19
Source File: connector.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def fetchall(self): try: return self.cursor.fetchall() except pymysql.ProgrammingError, msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None
Example #20
Source File: connector.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def fetchall(self): try: return self.cursor.fetchall() except pymysql.ProgrammingError, msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None
Example #21
Source File: connector.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def execute(self, query): retVal = False try: self.cursor.execute(query) retVal = True except (pymysql.OperationalError, pymysql.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1])
Example #22
Source File: connector.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def fetchall(self): try: return self.cursor.fetchall() except pymysql.ProgrammingError, msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None
Example #23
Source File: connector.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def execute(self, query): retVal = False try: self.cursor.execute(query) retVal = True except (pymysql.OperationalError, pymysql.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1])
Example #24
Source File: connector.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def fetchall(self): try: return self.cursor.fetchall() except pymysql.ProgrammingError, msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) return None
Example #25
Source File: test_sql.py From vnpy_crypto with MIT License | 5 votes |
def setup_method(self, request, datapath): _skip_if_no_pymysql() import pymysql try: # Try Travis defaults. # No real user should allow root access with a blank password. self.conn = pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') except: pass else: return try: self.conn = pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: pytest.skip( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") except pymysql.Error: pytest.skip( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") self.method = request.function
Example #26
Source File: test_sql.py From vnpy_crypto with MIT License | 5 votes |
def setup_class(cls): _skip_if_no_pymysql() # test connection import pymysql try: # Try Travis defaults. # No real user should allow root access with a blank password. pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') except: pass else: return try: pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: pytest.skip( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ") except pymysql.Error: pytest.skip( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf. ")
Example #27
Source File: test_sql.py From recruit with Apache License 2.0 | 5 votes |
def setup_method(self, request, datapath): pymysql = pytest.importorskip('pymysql') pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') try: pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: raise RuntimeError( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf.") except pymysql.Error: raise RuntimeError( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf.") self.method = request.function
Example #28
Source File: test_sql.py From recruit with Apache License 2.0 | 5 votes |
def setup_class(cls): pymysql = pytest.importorskip('pymysql') pymysql.connect(host='localhost', user='root', passwd='', db='pandas_nosetest') try: pymysql.connect(read_default_group='pandas') except pymysql.ProgrammingError: raise RuntimeError( "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf.") except pymysql.Error: raise RuntimeError( "Cannot connect to database. " "Create a group of connection parameters under the heading " "[pandas] in your system's mysql default file, " "typically located at ~/.my.cnf or /etc/.my.cnf.")