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
Can not connect to FB services if set ISC_USER & ISC_PASSWORD by os.environ[ ... ] [PYFB69] #43
Comments
Commented by: @pmakowski read https://docs.python.org/2/library/os.html#process-parameters you need putenv to change environment variables |
Commented by: @pavel-zotov Philippe, thank you for reply. import os os.environ["ISC_USER"] = user_name db_file="$(DATABASE_LOCATION)bugs.core_4337.fdb" fn_nul = open(os.devnull, 'w') - ? |
Commented by: @pcisar It's not FDB problem, because FDB handles ISC_USER & ISC_PASSWORD in service calls just fine - if it's properly set before. Setting values to os.environ may not always work, see https://docs.python.org/2/library/os.html#os.environ |
Commented by: @pavel-zotov > FDB handles ISC_USER & ISC_PASSWORD in service calls just fine - if it's properly set before. Setting values *DOES* work correctly, either via os.environ[] or os.putenv(). Pease see attached screen an following samples: case-1: using os.putenv() C:\>set isc_user= C:\>set isc_password= C:\>python case-2: using os.environ[...] = ... C:\>set isc_user= C:\>set isc_password= C:\>python |
Commented by: @pavel-zotov Unfortunately, one can not attach file in this branch of tracker. |
Commented by: @pcisar Well, I see where the problem is. FDB services.connect() reads environment variables on loading into memory (when you import fdb into python), not on call to it. So if you define environment variables at OS shell level or before fdb is imported, it works as expected. See: > python Because there is a clear anomaly how fdb.connect and fdb.services.connect handle environment variables, I'll fix services.connect to read environment on call, like fdb.connect/create_database does. |
Modified by: @pcisarFix Version: 1.7 [ 10803 ] |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: @pavel-zotov
test #1
#####
C:\>set isc_user
ISC_USER=SYSDBA
C:\>set isc_password
ISC_PASSWORD=masterke
C:\>python
ActivePython 2.7.8.10 (ActiveState Software Inc.) based on
Python 2.7.8 (default, Jul 2 2014, 19:50:44) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from fdb import services
>>> print( services.connect(host='localhost').get_home_directory() )
C:\MIX\firebird\fb40\
>>> ^Z
(OK, we able to connect to FB service manager using ISC_* environment variables that are assigned in OS command prompt)
test #2
#####
C:\>set isc_user=
C:\>set isc_password=
C:\>python
...
>>> import os
>>> from fdb import services
>>>
>>> os.environ["ISC_USER"] = 'SYSDBA'
>>> os.environ["ISC_PASSWORD"] = 'masterke'
>>> print( services.connect(host='localhost').get_home_directory() )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\fdb\http://services.py", line 186, in connect
raise fdb.ProgrammingError('A password is required to use'
fdb.fbcore.ProgrammingError: A password is required to use the Services Manager.
Seems that inside python we can not use env. variables ? But they *are* defined:
>>> print os.environ.get('ISC_USER')
SYSDBA
>>> print os.environ.get('ISC_PASSWORD')
masterke
Commits: d7d5802 FirebirdSQL/fbt-repository@dab9229 FirebirdSQL/fbt-repository@740133f FirebirdSQL/fbt-repository@35f24c7 FirebirdSQL/fbt-repository@8bf47ed FirebirdSQL/fbt-repository@0926318 FirebirdSQL/fbt-repository@d9eaf16
The text was updated successfully, but these errors were encountered: