odbc

OdbcConnection Text Driver ignores scheme.ini settings

邮差的信 提交于 2020-01-14 04:34:44
问题 Here is my code: OdbcConnection conn = new OdbcConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};DSN=scrapped.csv"); conn.Open(); OdbcCommand foo = new OdbcCommand(@"SELECT * FROM [scrapped.csv] WHERE KWOTA < 100.00", conn); IDataReader dr = foo.ExecuteReader(); StreamWriter asd = new StreamWriter("outfile.txt"); while (dr.Read()) { int cols = dr.GetSchemaTable().Rows.Count; for (int i = 0; i < cols; i++) { asd.Write(string.Format("{0};",dr[i].ToString())); } asd.WriteLine(); } asd

OdbcConnection Text Driver ignores scheme.ini settings

♀尐吖头ヾ 提交于 2020-01-14 04:34:06
问题 Here is my code: OdbcConnection conn = new OdbcConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};DSN=scrapped.csv"); conn.Open(); OdbcCommand foo = new OdbcCommand(@"SELECT * FROM [scrapped.csv] WHERE KWOTA < 100.00", conn); IDataReader dr = foo.ExecuteReader(); StreamWriter asd = new StreamWriter("outfile.txt"); while (dr.Read()) { int cols = dr.GetSchemaTable().Rows.Count; for (int i = 0; i < cols; i++) { asd.Write(string.Format("{0};",dr[i].ToString())); } asd.WriteLine(); } asd

How to explain why ODBC requires a database driver

允我心安 提交于 2020-01-13 19:08:51
问题 A month ago, I was showing a buddy how use .NET to query MySQL. It worked just fine, but he didn't understand why we needed a "driver" for MySQL in conjunction with ODBC. He though ODBC would be enough. When he asked me why, I did my best, but my answer came up short. What is the correct explanation for this question? 回答1: The reason you need a driver is that ODBC is not in itself a driver for talking to databases: it's an abstraction and an API. Essentially it is an adaptor layer designed to

how to catch specific pyodbc error message

给你一囗甜甜゛ 提交于 2020-01-13 07:57:28
问题 I trid the following code, import pyodbc try: pyodbc.connect('DRIVER={%s};SERVER=%s;DATABASE=%s;UID=%s;PWD=%s' % (driver, server, database, uid, password)) except pyodbc.Error, err: logging.warn(err) The error message format i get is ('HY000', "[HY000] [MySQL][ODBC 5.1 Driver]Access denied for user 'root'@'192.168.2.27' (using password: YES) (1045) (SQLDriverConnect)") I want to receive just the message part of the error i.e. Access denied for user 'root'@'192.168.2.27'(using password: YES) I

Multiple result sets returned from php ODBC query?

大憨熊 提交于 2020-01-13 06:45:49
问题 I'm running the following query in a PHP ODBC connection to a MSSQL sever: DECLARE @weekStart SMALLDATETIME; SET @weekStart = DATEADD(d,0, DATEDIFF(d,0,GETDATE())); -- weekStart = TODAY @ 00:00:00 -- per http://weblogs.sqlteam.com/jeffs/archive/2007/01/02/56079.aspx SET @weekStart = DATEADD(d, 1-DATEPART(dw, GETDATE()), @weekStart); -- subtract to last SUN @ 00:00:00 SELECT DATEDIFF(week, Run_Date, @weekStart) AS weeksAgo ,MIN(Current_List) AS list ,COUNT(*) AS cnt ,SUM(NoContact_90Days) AS

Getting list of odbc drivers available in windows 7 using python

醉酒当歌 提交于 2020-01-12 18:50:55
问题 I am trying to write a generic database connector class in python. For this I want to first check what drivers are installed on the machine and throw an error if the required drivers are missing in the machine. Is there a way to do this in python? 回答1: I realise this is a late reply ... but just stumbled across the answer myself; in case anyone else is looking for an answer. pyodbc has a method which returns a list of installed ODBC drivers. Granted, it's just a list of the driver names, so

Getting list of odbc drivers available in windows 7 using python

折月煮酒 提交于 2020-01-12 18:50:35
问题 I am trying to write a generic database connector class in python. For this I want to first check what drivers are installed on the machine and throw an error if the required drivers are missing in the machine. Is there a way to do this in python? 回答1: I realise this is a late reply ... but just stumbled across the answer myself; in case anyone else is looking for an answer. pyodbc has a method which returns a list of installed ODBC drivers. Granted, it's just a list of the driver names, so

ODBC v Libpq: C library for PostgreSQL

跟風遠走 提交于 2020-01-12 10:09:30
问题 I am going to be using a C library to connect and use a PostgreSQL database, I was wondering what are the pros and cons to ODBC and Libpq. From what I can tell, libpq seems to be faster but I was not able to get any clear answers or benchmarks. Also, is there any other library that might be better then ODBC/Libpq. 回答1: ODBC is useful if you want a standard adapter that speaks a similar API for different databases. I personally think it's an awful API, but it's widely understood and well

ODBC v Libpq: C library for PostgreSQL

自作多情 提交于 2020-01-12 10:06:01
问题 I am going to be using a C library to connect and use a PostgreSQL database, I was wondering what are the pros and cons to ODBC and Libpq. From what I can tell, libpq seems to be faster but I was not able to get any clear answers or benchmarks. Also, is there any other library that might be better then ODBC/Libpq. 回答1: ODBC is useful if you want a standard adapter that speaks a similar API for different databases. I personally think it's an awful API, but it's widely understood and well

How to use windows authentication to connect to MS SQL server from windows workstation in another domain with Python

拥有回忆 提交于 2020-01-12 07:43:09
问题 I'm trying to connect to SQL server 2000 installed on Windows server 2003 from Windows Server 2008 R2 using Python 3.4 and pyodbc module. Those servers are in different AD domains. Windows only authentication is enabled on SQL server and I can't change that. drv = '{SQL server}' svr = 'sql.my-domain.local' usr = 'my-domain.local\testuser' pwd = 'password' db = 'testdb' pyodbc.connect(driver=drv, server=svr, user=usr, password=pwd, database=db) The connection above fails with the following