Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to startup force mount with a pfile. Please advise how to do this through cx_oracle #295

Closed
ianmacl opened this issue Apr 17, 2019 · 3 comments
Labels
enhancement patch available Awaiting inclusion in official release

Comments

@ianmacl
Copy link

ianmacl commented Apr 17, 2019

For general questions:

I am trying to do the equivalent of "startup force mount pfile='/tmp/pfile.ora'" from a cx_oracle connection.

When I try to do this, I get DatabaseError: ORA-00900: invalid SQL statement both with a PRELIM_AUTH connection and a normal connection.

There is also the startup command, but it does not allow one to specify a pfile.

  1. What is your version of Python? Is it 32-bit or 64-bit?
    Python 2.6.6 64 bit

  2. What is your cx_Oracle version?
    5.1.2

  3. What exact command caused the problem (e.g. what command did you try to install with)? Who were you logged in as?
    cur.execute("startup force mount pfile='/tmp/pfile.ora'")

  4. What error(s) you are seeing?
    DatabaseError: ORA-00900: invalid SQL statement

  5. What OS (and version) is Python executing on?
    RHEL 6.3

  6. What is your version of the Oracle client (e.g. Instant Client)? How was it installed? Where is it installed?
    Client version 11.2.0.3.0
    Installed via custom RPM.
    Installed at
    /usr/lib64/*
    /usr/include/oracle/11.2/client64/*

  7. What is your Oracle Database version?
    11.2.0.4

  8. What is the PATH environment variable (on Windows) or LD_LIBRARY_PATH (on Linux) set to? On macOS, what is in ~/lib?
    not set

  9. What Oracle environment variables did you set? How exactly did you set them?
    None

  10. Do you have a small, single Python script that immediately runs to show us the problem?

conn_perm = cx_Oracle.connect(conn_string % (user, password, conn_protocol, cname, port, service_name, cert_dn), mode=cx_Oracle.SYSDBA | cx_Oracle.PRELIM_AUTH, threaded=threaded)
cur = conn.cursor()
cur.execute("create spfile='/tmp/spfile.ora' from pfile")
cur.execute("alter system set spfile='/tmp/spfile.ora'")
cur.execute("create pfile='/tmp/pfile.ora' from spfile='/tmp/spfile.ora'")
# all the above work fine

cur.execute("startup force mount pfile='/tmp/pfile.ora'")  # This statement causes an error
@anthony-tuininga
Copy link
Member

The "startup" command is a SQL*Plus command. You need to use the startup method instead. That currently doesn't support pfile, though. So I've marked this as an enhancement.

@anthony-tuininga anthony-tuininga added the patch available Awaiting inclusion in official release label Dec 4, 2019
@anthony-tuininga
Copy link
Member

Support has now been added. To startup a database as you are requesting you would perform something like this. See the sample for details.

# the connection must be in PRELIM_AUTH mode
connection = cx_Oracle.connect("/",
        mode = cx_Oracle.SYSDBA | cx_Oracle.PRELIM_AUTH)
connection.startup(force=True, pfile="/tmp/pfile.ora")

# the following statements must be issued in normal SYSDBA mode
connection = cx_Oracle.connect("/", mode = cx_Oracle.SYSDBA)
cursor = connection.cursor()
cursor.execute("alter database mount")
cursor.execute("alter database open")

@anthony-tuininga
Copy link
Member

cx_Oracle 8 was just released with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement patch available Awaiting inclusion in official release
Projects
None yet
Development

No branches or pull requests

2 participants