How to access ODBC databases ?

T

Timothy Madden

Hello

I would like to use a database through ODCB in my python application. I
have Slackware Linux, but I would not mind a portable solution, since
python runs on both Unixes and Windows.

I would like a free/open-source solution and the python module for ODBC
access that I have found is *pyodbc*, but the problem is it fails to
connect to my database with an error like:
Unicode};Servername=127.0.0.1;UID=pikantBlue;Database=pikantBlue')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('0', '[0] [nxDC (202) (SQLDriverConnectW)')


Do you know what the problem is ? My database is working and I can
connect with *psql -U pikantBlue*, and also my ODBC installation is
working and I can connect with *isql pikantBlue*.

From python I can also connect with the *pyodb* module, which is
another module for ODBC access, but pyodb does not have query parameters
and all
the functions in the DB api, it is only meant the be a simple way to
acccess ODBC.

Do you know why my *pyodbc* module would not connect, when others will ?
Do you know other modules to use ODBC in python ?

Thank you
Timothy Madden
 
T

Timothy Madden

Martin said:
Timothy Madden wrote:
Unicode};Servername=127.0.0.1;UID=pikantBlue;Database=pikantBlue')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('0', '[0] [nxDC (202) (SQLDriverConnectW)')

Not sure (i.e. wild guess) but that line makes me think it has something
to do with the encoding, is it possible to try a different driver?
Thank you.

Slackware also comes with mysql, I guess I could try to install and
register a driver for it in my unixODBC installation.

What about the encoding ? What should I be looking for in this case ?
Indeed when I try
createdb --encoding=UTF-8 pikantBlue
I get the message that the server's /LC_TYPE settings require encoding
to be LATIN1/. What should I do about it ? Should I have been more
careful about the configure options when compiling postgresql ? I also
tried pyodbc on Ubuntu with the database installed with apt-get and I
still get the same problem.

Thank you
Timothy Madden
 
T

Timothy Madden

Martin said:
Timothy said:
Martin said:
Timothy Madden wrote:
<cut>
conn = pyodbc.connect('DRIVER={PostgreSQL
Unicode};Servername=127.0.0.1;UID=pikantBlue;Database=pikantBlue')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>

pyodbc.Error: ('0', '[0] [nxDC (202) (SQLDriverConnectW)')

Not sure (i.e. wild guess) but that line makes me think it has
something to do with the encoding, is it possible to try a different
driver?
Thank you.

Slackware also comes with mysql, I guess I could try to install and
register a driver for it in my unixODBC installation.

What about the encoding ? What should I be looking for in this case ?
Indeed when I try
createdb --encoding=UTF-8 pikantBlue
I get the message that the server's /LC_TYPE settings require encoding
to be LATIN1/. What should I do about it ? Should I have been more
careful about the configure options when compiling postgresql ? I also
tried pyodbc on Ubuntu with the database installed with apt-get and I
still get the same problem.

Thank you
Timothy Madden

According to this:
http://psqlodbc.projects.postgresql.org/faq.html#2.5
You could try the 'PostgreSQL ANSI' driver.

Thank you.

The precompiled psqlodbca.so driver from apt-get worked on one of the
Ubuntu machines that I tried.

I would still like o use the Unicode driver if possible. Do you know
what the problem could be ? Or where ? pyodbc/unixODBC/psqlodbcw.so ?

Thank you,
Timothy Madden
 
T

Timothy Madden

Martin said:
Timothy Madden wrote:
<cut>
[...]
It has been a couple of years, but I remember vaguely that back in the
days of PossgreSQL 6, if you want ODBC support you needed to compile PG
a bit different then normal, I am not really sure what options those
where and if this still applies, I decided to not use ODBC because it
resulted in an undesirable effect somewhere else. Though I am not sure
if that is still the case.

Sorry to hear that. I think ODBC is an important step towards
DBMS-independent applications, or even database applications portable
over DBMSs.

Yes, I know, everyone says such applications are so far from reality
that they are not worth any effort trying. I still consider that ODBC is
at least a step, and I am only sorry PostgreSQL has a poor ODBC driver
(no large objects natively). Python also has a unified independent
database interface with the DB API, and so does php and maybe other
products.

Thank you for your help,
Timothy Madden
 
Joined
Sep 6, 2009
Messages
5
Reaction score
0
i have error in line 3 and 7 indentifier expected.........
class A {
int i;
i = 8;
}
class B extends A{
int i;
i = 76;
void add(int a) {
int i;
i=a;

System.out.println("value of

i"+super.i);
System.out.println("value of

i"+this.i);
System.out.println("vaue of i="+
i);
}
}
 
D

Dennis Lee Bieber

(no large objects natively). Python also has a unified independent
database interface with the DB API, and so does php and maybe other
products.
The DB-API is only a specification though, and not an
implementation... You still need modules like MySQLdb, pysqlite (or the
renamed version now supplied with Python), etc. to create DB-API
applications.

ODBC is just another layer... Where MySQLdb/pysqlite/etc. directly
"talk" to the database engine, ODBC sits between the application and the
DBMS -- you still need an engine specific driver, and a language
specific interface to the ODBC layer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top