I am trying to create database from abx python script using sqlite3 package. I am below two observation.
1) When I created database in /tmp/location script is able to create. But I could not locate the database file in the abx pods or vra node. Where this "example.db" will be residing?
def handler(context, inputs):
conn = sqlite3.connect('/tmp/example.db')
2) When i change the path to /root or /home folder for database location. If failed to create the db with below error. Any suggestion/debugging steps for below error.
Traceback (most recent call last):
File "abx_wrapper.py", line 286, in main
response = exec_function(wrapperCtx, request, f)
File "abx_wrapper.py", line 192, in exec_function
funcResult = handle(ctx, req)
File "/function/client_main.py", line 5, in handler
conn = sqlite3.connect('/home/example.db')
sqlite3.OperationalError: unable to open database file
I don't know where it would be stored, but can I ask why you are trying to create this locally? ABX actions are FaaS and as so I would expect any data stored to be destroyed when the function is done running, an external DB that is called using an ABX action would seem to be more appropriate.
This won't work.
ABX on-prem runs each function inside its own container; the filesystem of the container is marked as read only.
You will have to connect to a database that is "remote" to the running function.
My requirement is to persist the data in the database , either internal database or external db server which can be accessed by other ABX actions. As per limitation in abx seems I can't use sqlite3. So I have to opt for external database server. I have ms sql 2012 server installed which I want to access from my abx action (python script). Seems abx python does not contains pymssql package which I can use in the script and abx does not allow us to install any package in the script as well.
I have other database option like mangodb or cassendra which I can access using rest from python script but seems "requests" package is not available in the action.
Any suggestion ? please.
If a package is not available, you would not "install" it like on a normal server. Within the ABX action you add it as a dependency.
i.e. if you want to write a python script to make a rest API call, you would still issue the "import requests" command within your script but you also add "requests" as a Dependency on the ABX action.
Thank you for your response. It was really helpful.
ABX container have limitation to connect the mssql server. Though I was able to import "pymssql" after providing the package name in "dependency" but container does not contains the driver. Got the below error in abx action. I tired the same command in windows setup having python 3.5 worked fine there.
ymssql.connect(host="192.168.10.100", user="sa", password="Password123!", database="abxdb")
File "src/_mssql.pyx", line 677, in _mssql.MSSQLConnection.__init__
_mssql.MSSQLDriverException: Connection to the database failed for an unknown reason
I tried with "pyodbc" python package to connect mssql server and got the similar kind of driver exception.
I have another postgresql server installed. To connect the postgresql it uses "psycopg2" python package but ABX is not able to include this package while deploying the container and throwing 404 not found error.
Please help me to connect the DATA BASE server if are you aware of. I just need to persist the data.