Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-129

"Commands out of sync; you can't run this command now" when call system tables

Details

    • Bug
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Not a Bug
    • 1.0.4
    • N/A
    • DBAPI 2.0
    • None
    • MariaDB 10.5.7

    Description

      When I try to get system tables with this sample:

      db_connection = db_connector.connect(....)
      db_cursor = db_connection.cursor(prepared=True)
      db_cursor.execute("select version()")
      server_version = Version(db_cursor.fetchone()[0])
      db_cursor.execute("SHOW VARIABLES like 'have_ssl'")
      have_ssl = str2bool(db_cursor.fetchone()[1], raise_exc=True)
      query = "select TABLE_NAME from information_schema.tables where TABLE_SCHEMA=%s and TABLE_NAME=%s"
      try:
          db_cursor.execute(query, ("mysql", "global_priv"))
      

      If fails with:
      Commands out of sync; you can't run this command now
      Using the same code with the MySQL python connector will work.

      Attachments

        Activity

          georg Georg Richter added a comment -

          This is expected behavior, since MariaDB Connector/Python uses unbuffered resultsets by default.

          If you want to buffer your results, you need to declare a cursor with keyword buffered=True . For using multiple cursors on the same connection with unbuffered result set you have to specify cursor_type when creating the cursor.

          georg Georg Richter added a comment - This is expected behavior, since MariaDB Connector/Python uses unbuffered resultsets by default. If you want to buffer your results, you need to declare a cursor with keyword buffered=True . For using multiple cursors on the same connection with unbuffered result set you have to specify cursor_type when creating the cursor.
          mariaTux Frank added a comment -

          The final problem is, that both connectors has the same option, but in different manner.
          On the MySQL one, this is needed to enable prepared query's. It will be nice, when there will be an section in the documentation, that will inform about such elementary differences.
          See:
          https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor.html

          mariaTux Frank added a comment - The final problem is, that both connectors has the same option, but in different manner. On the MySQL one, this is needed to enable prepared query's. It will be nice, when there will be an section in the documentation, that will inform about such elementary differences. See: https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor.html

          People

            georg Georg Richter
            mariaTux Frank
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.