Can environment variable be part of the Driver path specified inside odbc.ini file ?
something like below.
[SYB]
Driver = ${DRIVER_PATH}/libsybdrvodb.so
odbc driver installation path is different across the environments and i do not want to hard code the absolute path which will require maintaining more than one odbc.ini file.
I've never seen an odbc.ini file where anything like that was done. However, you could use an environment variable to help construct a (DSN-less) connection string that you pass to pyodbc, e.g.,
conn_str = (
f"DRIVER={os.getenv('MSODBCSQL_NAME')};"
r"SERVER=.\SQLEXPRESS;"
"DATABASE=myDb;"
"Trusted_Connection=yes"
)
print(conn_str)
# DRIVER=SQL Server Native Client 11.0;SERVER=.\SQLEXPRESS;DATABASE=myDb;Trusted_Connection=yes
Related
I'm running Spark in 'standalone' mode on a local machine in Docker containers. I have a master and two workers, each is running in its own Docker container. In each of the containers the path /opt/spark-data is mapped to the same local directory on the host.
I'm connecting to the Spark master from R using sparklyr, and I can do a few things, for example, loading data into Spark using sparklyr::copy_to.
However, I cannot get sparklyr::spark_read_csv to work. The data I'm trying to load is in the local directory that is mapped in the containers. When attaching to the running containers I can see that the file I'm trying to load does exist in each of the 3 containers, in the local (to the container) path /opt/spark-data.
This is an example for the code I'm using:
xx_csv <- spark_read_csv(
sc,
name = "xx1_csv",
path = "file:///opt/spark-data/data-csv"
)
data-csv is a directory containing a single CSV file. I've also tried specifying the full path, including the file name.
When I'm calling the above code, I'm getting an exception:
Error: org.apache.spark.sql.AnalysisException: Path does not exist: file:/opt/spark-data/data-csv;
I've also tried with different numbers of / in the path argument, but to no avail.
The documentation for spark_read_csv says that
path: The path to the file. Needs to be accessible from the
cluster. Supports the ‘"hdfs://"’, ‘"s3a://"’ and ‘"file://"’
protocols.
My naive expectation is that if, when attaching to the container, I can see the file in the container file system, it means that it is "accessible from the cluster", so I don't understand why I'm getting the error. All the directories and files in the path are owned by rood and have read permissions by all.
What am I missing?
try without "file://" and with \\ if your are Windows user.
I'm attempting to set up an ODBC connection on an EC2 server on our companies network. Have been reading Snowflake documentation here.
Following the documentation, I used yum to download and install the driver by adding a file /etc/yum.repos.d/snowflake-odbc.repo and then populating it with:
[snowflake-odbc]
name=snowflake-odbc
baseurl=https://sfc-repo.snowflakecomputing.com/odbc/linux/2.22.1/
gpgkey=https://sfc-repo.snowflakecomputing.com/odbc/Snowkey-37C7086698CB005C-gpg
I then ran yum install snowflake-odbc
This appears to have added a connection to our existing /etc/odbc.ini file:
[snowflake]
Description=SnowflakeDB
Driver=SnowflakeDSIIDriver
Locale=en-US
SERVER=SF_ACCOUNT.snowflakecomputing.com
PORT=443
SSL=on
ACCOUNT=SF_ACCOUNT
Chancing my luck I tested this connection in it's current format but it doesn't work. Seems I need to locate some more info / name value pairs and I'm unsure where to get them:
Driver= wants a path to a .so file that I thought would have been installed with my steps outlined above. Not sure where to find this file or what path to use?
When I tested the connection the error I received said I was missing a UID.
The section of the documentation on dns entries has additional details of which settings can be added to odbc.ini, including an example
Driver = /usr/jsmith/snowflake_odbc/lib/libSnowflake.so
Description =
server = yz23456.us-east-1.snowflakecomputing.com
role = analyst
database = sales
warehouse = analysis
Does anyone know where can I find out which settings I need to add to get the odbc connection to work?
I'm trying to config a connection with SQLBase with odbc driver on Windows and I never did that, but I'm getting the error:
Connection failed with SQL State: "HY092"
I'm using the Windows ODBC Administrator to try add the connection. In the field "Config Filename (INI)" of the configuration screen I put: "C:\Program Files (x86)\Centura\sql.ini" and I add "C:\Program Files (x86)\Centura\" to the PATH system variable.
In the application (.NET) I'm getting the message:
ERROR [HY092] [Gupta][ODBC Driver]Invalid attribute/option identifier
My sql.ini file has the content:
[win32client]
clientname=CWBXXX
[win32client.dll]
comdll=sqlws32
[win32client.
serverpath=server3,<SERVER_IP>,2155/<BASE_NAME>
Anyone could help me? Thank you.
Good to see you are using SQLBase . Awesome.
Two important settings to get right.
1) Make sure you are using the correct ODBC administrator
I'm guessing 32 bit in %systemdrive%\Windows\SysWoW64\odbcad32.exe.
If not , use the 64bit one in %systemdrive%\Windows\System32\odbcad32.exe.
Under System DSN tab Add the correct driver for the database. Either 'Centura SQLBase 3.6 32bit Driver' or the 'Gupta SQLBase 12.x' driver if you are running SQLBase 12.
Under the Configure Tab, specify the Data Source Name that you will use in your sql.ini. THEY MUST MATCH.
2)a. Make sure you only ever have 1 sql.ini on the client. Ever.
2)b. sql.ini needs the ODBC driver specified in the client section:
[win32client.dll]
comdll=sqlodb32
[odbcrtr]
odbctrace=off
longbuffer=32767
buffrow=10000
remotedbname=[dB Name specified in ODBC] ,
DSN=[Data Source Name specified in ODBC]
(without the square brackets eg. remotedbname=MyDatabase,DSN=MyDatasetName whatever names you have specified in ODBC admin.)
I do not have the permission to edit the system-wide odbc.ini file, therefore I am searching for alternative ways to specify connection parameters towards Vertica.
I have unpacked the needed libraries to a certain location, and am attempting to create a connection string from my "custom" config file.
Is it possible to explicitly specify the path to the driver (and any other necessary parameters) when using pyodbc.connect?
Example intention (fails with the error below):
conn = pyodbc.connect("DRIVER=path/to/libverticaodbc.so;...")
Error:
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')
Alternatively, is there another option to use odbc.ini files other than the ones at /etc/, e.g. through setting an environment variable?
I recommend to avoid the use of ODBC driver to connect to Vertica .
Vertica release native driver for python , see attach full details and examples :
https://github.com/uber/vertica-python
I hope you will find it us-full
Thanks
You can put a file called .odbc.ini in your home directory which will be for user specific ODBC settings.
http://www.unixodbc.org/odbcinst.html
I'm trying to set up dsn with qt and i cant get it to work. The dsn does work with isql.
I'm using ubuntu 12.04
POSTGRES is the dsn.
connection line:
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("localhost");
db.setDatabaseName("POSTGRES");
error:
FATAL: database "POSTGRES" does not exist.
I don't understand why qt doesn't do the look up to find the database behind. i made symlink (usr/local/etc) to odbc.ini and have odbcinst.ini aswell sqli does work with POSTGRES dsn.
Perhaps where will qt look for these files? Googled for 3 days now without success
I kind of gave up cant solve this thank you for any help.
I believe your problem is that you're using the wrong driver. According to the Qt documentation, you need to be using the ODBC driver for DSN files to work - for example:
db = QSqlDatabase::addDatabase("QODBC");
Also note that, again according to the Qt documentation, if you're trying to pass a DSN filename to setDatabaseName, then it MUST have a ".dsn" file extension:
For the QODBC driver, the name can either be a DSN, a DSN filename (in which case the file must have a .dsn extension), or a connection string.
And, finally, it must be listed in your odbc.ini.