Here's what I've tried:
-Find Vista's ODBC Data Source Manager* through search,
-Add a new File Data Source*, selecting Driver for Microsoft Access (*.mdb), and selecting my mdb file of interest,
-import pyodbc from python shell and try:
pyodbc.connect("DSN=<that Data Source I just created>")
I get the following error message (Portuguese**):
Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Nome da fonte de dados n\xe3o encontrado e nenhum driver padr\xe3o especificado (0) (SQLDriverConnectW)')
Which translates as "Data source name not found and no standard driver specified".
What am I doing wrong?
How to get it right?
Also, I searched the web for documentation but found nothing worth much, could anyone recommend any documentation?
*Names may not be completely accurate because my Windows is in Portuguese.
**No, Portuguese doesn't have '3' and '\' as letters, these are misprinted special characters
DSN= is only used for a system or user DSN.
For a DSN File, you need to use FILEDSN=c:\myDsnFile.dsn
http://www.connectionstrings.com/ is your best friend.
I had a similar problem with pyodbc although not with Access but a different ODBC driver.
This is what helped me.
http://robertoschiabel.wordpress.com/2008/02/28/windows-x64-32bit-odbc-vs-64bit-odbc/
(here is the appropriate KB article in case this URL goes away. http://support.microsoft.com/kb/942976/en-us )
Our previous server hardware died and we had to quickly redeploy on a 64 bit OS because that is all we had that was available. Using the normal ODBC admin tool I added the appropriately named DSN but it still claimed it wasn't found. Only when running the special 32-bit version of the ODBC admin, was I able to define a DSN that my script using pyodbc could find.
I use odbc module (included in ActiveState Python), but tested pyodbc and for me works:
#db = odbc.odbc('northwind')
#db = odbc.odbc('Driver={Microsoft Access Driver (*.mdb)};Dbq=Nwind.mdb;Uid=;Pwd=;')
#db = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=Nwind.mdb;Uid=;Pwd=;')
db = pyodbc.connect('DSN=northwind')
Of course commented connections works too.
I configured nothwind as user DSN so you probably will have to configure your ODBC database connection as User DSN or System DSN, or without configuring in ODBC Administrator you can use ConnectString where you can point at your .mdb file.
It's smart to list your odbc connections with pyodbc to see what are you using. Make sure you use appropriate pyodbc 32 bit Python 32 bit driver. If you want to use 64bit access files you should use 64 bit MS Acceess which provides driver.
sources = pyodbc.dataSources()
keys = sources.keys()
for key in keys:
print key
Related
I am having a problem with connecting to data in SQL database.
I am not sure if I don't have the certain driver or if the code I am using is incorrect. Could someone please help guide me in the right direction?
Below is the product license that I have after running Proc Setinit
Operating System: WX64_WKS.
Product expiration dates:
---Base SAS Software
14FEB2018
---SAS/STAT
14FEB2018
---SAS/GRAPH
14FEB2018
---SAS/Secure 168-bit
14FEB2018
---SAS/Secure Windows
14FEB2018
---SAS Enterprise Guide
14FEB2018
---SAS/ACCESS Interface to PC Files
14FEB2018
---SAS/ACCESS Interface to Microsoft SQL Server
31DEC2017
---SAS Workspace Server for Local Access
14FEB2018
---SAS/ACCESS to Amazon Redshift
31DEC2017
---High Performance Suite
14FEB2018
Below is product installed after I ran Proc Product_Status
16 proc Product_Status ; run;
For Base SAS Software ...
Custom version information: 9.4_M5
Image version information: 9.04.01M5P090617
For SAS/STAT ...
Custom version information: 14.3
For SAS/GRAPH ...
Custom version information: 9.4_M5
For SAS/ACCESS to Amazon Redshift ...
Custom version information: 9.42
For High Performance Suite ...
Custom version information: 2.2_M6
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4_M5
NOTE: PROCEDURE PRODUCT_STATUS used (Total process time):
real time 0.24 seconds
It seems like sas access to SQL server is not installed right?
I am also trying these codes to connect and all got the error. Which direction of code should I be using? ODBC or sqlsvr?
I tried sqlsvr and got this error message
Code:
LIBNAME database1 sqlsvr user=datareader password=myspassword DATAsrc=clientA;
Error:
LIBNAME database1 sqlsvr user=datareader password=XXXXXXX
DATAsrc=clientA;
ERROR: CLI error trying to establish connection: [Microsoft][ODBC
Driver Manager] Data source name not found and no default driver
specified ERROR: Error in the LIBNAME statement.
When I tried ODBC route, I got this message
Code:
LIBNAME database1 ODBC DSN=clientA User=datareader Password=myspassword ;
Error:
LIBNAME database1 ODBC DSN=clientA User=datareader Password=XXXXXXX;
ERROR: The ODBC engine cannot be found. ERROR: Error in the LIBNAME
statement.
Could someone please point me in the right direction? Should DSN be the name of the database of each client as "ClientA" etc or should it be the name of the server?
Thank you so much!
The SQLSRV library engine DATASRC= option should specify an entry shown in the "ODBC Data Source Administrator (64-bit)" application. You can add an entry, set (configure) the connection parameters and test the connection. Suppose you name your new DSN Sales History, the libname might be
libname OldSales sqlsrv datasrc="Sales History" user=... pass=...;
For the case of wanting to specify the server name, schema, port, connection persistence, etcetera directly in your SAS code you would use the NOPROMPT= option. The option value will be a semi-colon separated list of name=value pairs:
libname OldSales sqlsrv user=... pass=... noprompt="Server=<url or hostname><\instance-name-if-other-than-default>,<port-number-if-other-than-default>;Initial Catalog=<database-to-use-if-other-than-default>;..other connection parameters..";
Microsoft documentation "Using Connection String Keywords with SQL Server Native Client" is a great reference. Another good resource for examples is connectionstrings website. A NOPROMPT= value that seems correct, yet is not to working, may have or require unusual spacing or quoting.
For a small group of coders in a static data hosting environment the NOPROMPT= method will probably be OK and require no extra support (other than access) in a large organization. If the data hosting migrates or changes your SAS code will have to be changed.
In a larger context, especially in a SAS Server environment, you are best off having your IT support to create the DSNs that your SAS sessions will need. The DSNs will be the single gateway that all programs and users will use and coders and analysts will not have to get bogged down in the connection details.
I'm trying to connect to an MS SQL database from R (on a Mac) - after fiddling a lot with odbc.ini, odbcinst.ini, and installing freeTDS as described:
sudo port install freetds +mssql +odbc +universal
it now works on the Mac's command line level, but when trying to access it from R using the command:
con <- odbcConnect("myDSN", uid = "myID", pwd = "myPWD")
it just hangs and when forced to stop executing, I get 50+ of the following warnings:
In odbcDriverConnect("DSN=myDSN;UID=myID;PWD=myPWD") :
[RODBC] ERROR: state IM002, code 1421220112, message [iODBC][Driver Manager]Data source
name not found and no default driver specified. Driver could not be loaded
After having tried to make it work for about two days, I'm running out of suggestions. Can anybody help point me to what I am missing?
EDIT: It also works when running R on the virtual Windows machine. How do I get it to work on the Mac?
Did you first configure your MS SQL driver connection? If you have, then you should have a data source called "myDSN" in the OCBC Data Source dialog box.
Here is a great blog which gives step-by-step instructions and screen captures for what you need to do.
When you issue queries in R, R will try to talk to the ODBC data source called "myDSN". That data source knows what database you want (MS SQL) and also what the credentials (username/password) are needed to get access. This is the reason why you must configure the data source.
When I try to install sonarqube database I get some errors and database is not created
ActiveRecord::JDBCError: The driver encountered an unknown error: unable to choose type for timestamp from:
["datetime2", "datetime"]
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb:66
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:31
jdbc_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection_methods.rb:6
send at org/jruby/RubyKernel.java:2227
new_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:223
checkout_new_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:245
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:188
loop at org/jruby/RubyKernel.java:1519
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:184
mon_synchronize at jar:file:/C:/sonarqube/web/WEB-INF/lib/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/monitor.rb:191
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:183
connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:98
retrieve_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:326
retrieve_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:123
connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:115
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:440
up at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401
migrate at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383
upgrade_and_start at C:/sonarqube/web/WEB-INF/config/../lib/database_version.rb:62
automatic_setup at C:/sonarqube/web/WEB-INF/config/../lib/database_version.rb:74
(root) at C:/sonarqube/web/WEB-INF/config/environment.rb:239
load at org/jruby/RubyKernel.java:1094
(root) at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:1
load_environment at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:25
load_environment at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails_booter.rb:79
i was reading about and looks like database driver is not working alright
Any clues about how can i get this working on SQL Server?
There might be a problem with the locale settings of the database. In my case it helped to set the language for the sonarqube database user to "English". See here.
After a few tries, I changed the SQL driver (sqljdbc4.jar) to one directly from Microsoft, it looks like my previous driver was third party modified.
http://www.microsoft.com/en-us/download/confirmation.aspx?id=21599 this is the original mssql driver form jdbc.
http://www.sezok.de/sonar/sonar.html this guide was helpful too.
after changing driver, everything works OK
Hi I have configured the DSN settings for vertica in Ubuntu 10.10 32 bit version machine.
The settings are all fine and I have cross checked them.
Here is my odbc.ini file:
[VerticaDSN]
Description = VerticaDSN ODBC driver
Driver = /opt/vertica/lib/libverticaodbc_unixodbc.so
Servername = myservername
Database = mydbname
Port = 5433
UserName = myuname
Password = *******
Locale = en_US
Similarly I have a odbcinst.ini file.
when I run the command: isql -v VerticaDSN I get the following error:
[S1000][unixODBC][DSI] The error message NoSQLGetPrivateProfileString could not be found in the en-US locale. Check that /en-US/ODBCMessages.xml exists.
[ISQL]ERROR: Could not SQLConnect.
I have tried everything but I am not able to decipher this error.
Any help will be greatly appreciated.
You may be missing the Driver configuration section. Edit or create the file /etc/vertica.ini with the following content:
[Driver]
DriverManagerEncoding=UTF-16
ODBCInstLib=/usr/lib64/libodbcinst.so
ErrorMessagesPath=/opt/vertica/lib64
LogLevel=4
LogPath=/tmp
More information can be found in the Vertica Programmer's Guide in the section "Location of the Additional Driver Settings".
Searching the Internet about this issue I have seen that tons of people have been able to connect with tsql but not with isql or osql (which uses isql). I have had this same issue and have been researching and testing for the last week trying to figure out what the issue is. The thing is everyone has approached it from the angle of the ODBC when what I think it is is something to do with the Windows server or sql server config. I checked the logs on the windows server and see that the machine running the ODBC has hit it and tried to log in repeatedly but has not been able to. In the event viewer there are tons of entries showing the same thing, that the client machine is trying to log into SQL Server but is being refused by the host machine. That is the angle I am focusing on now and where I think the problem lies. If I get this resolved I will post again letting everyone know what I found out about this problem.
Thanks,
From the error we can see you are using unixODBC and I presume "DSI" is what Vertica calls itself as ODBC error text is formatted with entries in [] from left to right as the path though the different components (see Example diagnostic messages).
I presume that message should be "No SQLGetPrivateprofileString could be found". SQLGetPrivateProfileString is an API provided by the ODBC driver manager to read entries from the odbc.ini file. I believe it should be found in the libodbcinst.so shared object however, some distributions (e.g., Ubuntu/Debian) strip symbols from shared objects so it is difficult to verify this.
In your DSN, the driver is the file "/opt/vertica/lib/libverticaodbc_unixodbc.so". Although it is more usual to name the driver in the odbc.ini and add an entry to the odbcinst.ini file your DSN looks ok. e.g.:
/etc/odbcinst.ini:
[Easysoft ODBC-SQL Server SSL]
Driver=/usr/local/easysoft/sqlserver/lib/libessqlsrv.so
Setup=/usr/local/easysoft/sqlserver/lib/libessqlsrvS.so
Threading=0
FileUsage=1
DontDLClose=1
/etc/odbc.ini:
[SQLSERVER_SAMPLE_SSL]
Driver=Easysoft ODBC-SQL Server SSL
Description=Easysoft SQL Server ODBC driver
.
.
See in the above example doing it this way allows you to specify additional options associated with the driver like Threading (and a quick search on the net suggests Vertica can use Threading=1 which is less restrictive if using a threaded program) and DontDLClose. However, as I said things should work as you have them now.
Now the next bit depends on your platform and I didn't notice if you specified one. You need to examine that shared object for your ODBC Driver and see what it depends on. On Linux you do something like this:
$ ldd /usr/local/easysoft/sqlserver/lib/libessqlsrv.so
linux-gate.so.1 => (0xb76ff000)
libodbcinst.so.1 => /usr/lib/libodbcinst.so.1 (0xb75fe000)
libesextra_r.so => /usr/local/easysoft/lib/libesextra_r.so (0xb75fb000)
libessupp_r.so => /usr/local/easysoft/lib/libessupp_r.so (0xb75de000)
libeslicshr_r.so => /usr/local/easysoft/lib/libeslicshr_r.so (0xb75cd000)
libestdscrypt.so => /usr/local/easysoft/lib/libestdscrypt.so (0xb75c8000)
libm.so.6 => /lib/libm.so.6 (0xb75a2000)
libc.so.6 => /lib/libc.so.6 (0xb7445000)
libltdl.so.7 => /usr/lib/libltdl.so.7 (0xb743b000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7421000)
/lib/ld-linux.so.2 (0xb7700000)
libdl.so.2 => /lib/libdl.so.2 (0xb741d000)
which shows this ODBC driver depends on libodbcinst.so.1 and the dynamic linker found it. I imagine your Vertica driver should look similar in this respect although it is possible the Vertica driver dynamically loads this shared object itself on first being loaded. Either way, it looks like the Vertica driver cannot find the symbol SQLGetPrivateProfileString which is in libodbcinst.so so make sure a) you have libodbcinst.so b) your dynamic linker knows about it (how this is done depends on your platform - on Linux see /etc/ld.so.conf and LD_LIBRARY_PATH and the man page for ld.so) c) run ldd (or equivalent) on it to make there are no missing dependencies.
The vertica.ini file is probably where the driver stores driver specific configuration - some drivers do this. If the format of this file is like the odbc ones above it may also use SQLGetPrivateProfileString for this file as you can tell that ODBC API which file to use.
Beyond this I've no more ideas other than contact vertica.
Arun -- if you can let me know the version of the database and the version of the driver I can get you more detail. Also, I might try posting this on the official Vertica community forum.
http://my.vertica.com/forums/forum/application-and-tools-area/client-drivers/
If I had to guess what your issue is I think it might be related to this post :
http://my.vertica.com/forums/topic/odbc-on-linux-issue/
... specifically the comment at the end about 'ODBCInstLib'.
Is it possible to read the data stored in MS SQL server from R interface?
If it is I would be also thankful if anyone could show the way to do it.
Tried the RODBC package already?
http://cran.r-project.org/web/packages/RODBC/index.html
There's also the RJDBC package : http://www.rforge.net/RJDBC/
See also :
http://www.r-bloggers.com/connecting-to-sql-server-from-r-using-rjdbc/
I've applied RODBC function suggested by other users. LinkSQL Server RODBC Connection
library(RODBC)
dbhandle <- odbcDriverConnect('driver={SQL
Server};server=mysqlhost;database=mydbname;trusted_connection=true')
res <- sqlQuery(dbhandle, 'select * from information_schema.tables')
change two variables based on your Data table. 'server=mysqlhost;database=mydbname'
Niko, What operating system are you running? The answer to your question varies, depending on the platform you are using.
If you are using Windows (of any stripe), connecting to MSSQL Server via ODBC (RODBC) makes the most sense. When I connect to a MSSQL Server on Linux, I use JDBC as suggested by Joris. I would assume that JDBC is also the best solution for Macs, but I could very well be wrong.
There another option that seems to outperform RODBC and RJDBC
rsqlserver package written by agstudy.
Installation:
require(devtools)
install_github("rClr", 'jmp75')
install_github('rsqlserver', 'agstudy',args='--no-multiarch')
The latest library that allows you to connect to MSSQL databases is RSQLServer.
It can be found on GitHub and CRAN.
You can connect to SQL server using DBI package, which I think works better than RODBC. DBI is a database interface package for relational databases. for SQL I use it along with odbc package as in the example below.
Visit this page for full details: Database Queries with R
An example would be as follows
library(DBI)
library(odbc)
con <- dbConnect(odbc::odbc(), .connection_string = "driver={SQL Server}; server= ServerName; database=DatabaseName; trusted_conncetion=true"))
dbGetQuery(con,'Select * from Table')
library("RODBC")
dbhandle <- odbcDriverConnect('driver={SQL Server};server=;database=;trusted_connection=true')
currTableSQL<-paste("SELECT *
FROM ",sep="")
currTableDF<-sqlQuery(dbhandle,currTableSQL)