Re: [python-win32] Python 3.7: difficulties importing adodbapi after installation

2018-08-19 Thread Sibylle Koczian

Hello,

Am 17.08.2018 um 16:34 schrieb Vernon D. Cole:
The hassle is because I have not fulfilled my responsibility to keep 
adodbapi maintained properly for these last few years. I now work in a 
Linux shop and have almost nothing to do with databases, so my work on 
Windows database software keeps taking a back seat to other 
responsibilities.  This weekend, I will finally have some time.




Thank you for your answer - but now I've got something I really can't 
understand:


I can connect to MS Access databases (*.mdb and *.accdb), and I can 
execute SELECT queries (didn't try any writing to the databases yet) - 
as long as the field list doesn't contain a DateTime field. If it does, 
then the query is executed, but as soon as I try to get to the results, 
the program simply finishes. No error message of any kind, and if the 
call to curs.fetchall() (or a loop "for record in curs: ...") is 
enclosed in try ... finally, then not even the "finally" part seems to 
be reached.


This is new. Using Python 3.6 and earlier versions queries with DateTime 
fields in the field list had the expected results.


The same queries using pyodbc are executed correctly.

Script to try this (needs database and table informations, of course):
#
import logging
import adodbapi

# Connection information
cConnform = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};"
cDatabase = r"X:\Path\to\database\db.accdb"# or db.mdb

sql_nodate = """SELECT ID, Item FROM mytable WHERE ID > ?"""
sql_date = """SELECT ID, Item, datefield FROM mytable WHERE ID > ?"""

def exec_query(sql, params, conn):
curs = conn.cursor()
try:
curs.execute(sql, params)
logging.debug("Query executed: %s, Parameter: %s", sql, params)
result = curs.fetchall()
logging.debug("Results: %d", len(result))
finally:
logging.debug("Cursor closed.")
curs.close()
return result

def test(connstr):
testid = 700 # must be adapted
conn = adodbapi.connect(connstr)
try:
nodate = exec_query(sql_nodate, (testid,), conn)
logging.debug("Query without date field: %d records",
  len(nodate))
for record in nodate:
print(record)
withdate = exec_query(sql_date, (testid,), conn)
logging.debug("Query with date field")
for record in withdate:
print(record)
finally:
conn.close()
logging.debug("Fertig.")

def main():
logging.basicConfig(level=logging.DEBUG)
connstr = cConnform.format(cDatabase)
test(connstr)

if __name__ == "__main__":
main()

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Python 3.7: difficulties importing adodbapi after installation

2018-08-17 Thread Vernon D. Cole
The hassle is because I have not fulfilled my responsibility to keep
adodbapi maintained properly for these last few years. I now work in a
Linux shop and have almost nothing to do with databases, so my work on
Windows database software keeps taking a back seat to other
responsibilities.  This weekend, I will finally have some time.

  That said: this is an open invitation for someone to step in and help out.

On Fri, Aug 17, 2018 at 8:10 AM Sibylle Koczian 
wrote:

> Fresh install of Python 3.7 on Windows 10.
>
> Installed pywin32-223.win-amd64.py3.7.exe (from python.org) without
> error messages, but the adodbapi directory didn't contain apibase.py and
> so adodbapi couldn't be imported.
>
> Next step: "pip install adodbapi --upgrade" again seemed to work
> normally, but now 4 files contained line endings "\r\r\n":
> apibase.py
> is64bit.py
> process_connect_string.py
> server.py
> This caused an IndentationError at the first line continuation in
> apibase.py (whitespace after the \):
> line 249, pythonDateTimeConverter.DateObjectFromCOMDate,
>  dte=datetime.datetime.fromordinal(integerPart +
> self._ordinal_1899_12_31) \
>  + datetime.timedelta(milliseconds=floatpart*8640)
>
> I couldn't find differences to the module version in my Python 3.6
> installation, other than the line endings, so I copied the 4 files from
> there.
>
> Last problem: now adodbapi missed
> ...\python37\lib\site-packages\win32com\gen_py\dicts.dat. The second
> exception in the traceback said something about missing rights, so I
> opened a Python shell as administrator and imported adodbapi there. That
> created the file.
>
> Now everything works as it should, but why the hassle?
>
> Greetings
> Sibylle
> ___
> python-win32 mailing list
> python-win32@python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] Python 3.7: difficulties importing adodbapi after installation

2018-08-17 Thread Sibylle Koczian

Fresh install of Python 3.7 on Windows 10.

Installed pywin32-223.win-amd64.py3.7.exe (from python.org) without 
error messages, but the adodbapi directory didn't contain apibase.py and 
so adodbapi couldn't be imported.


Next step: "pip install adodbapi --upgrade" again seemed to work 
normally, but now 4 files contained line endings "\r\r\n":

apibase.py
is64bit.py
process_connect_string.py
server.py
This caused an IndentationError at the first line continuation in 
apibase.py (whitespace after the \):

line 249, pythonDateTimeConverter.DateObjectFromCOMDate,
dte=datetime.datetime.fromordinal(integerPart + 
self._ordinal_1899_12_31) \

+ datetime.timedelta(milliseconds=floatpart*8640)

I couldn't find differences to the module version in my Python 3.6 
installation, other than the line endings, so I copied the 4 files from 
there.


Last problem: now adodbapi missed 
...\python37\lib\site-packages\win32com\gen_py\dicts.dat. The second 
exception in the traceback said something about missing rights, so I 
opened a Python shell as administrator and imported adodbapi there. That 
created the file.


Now everything works as it should, but why the hassle?

Greetings
Sibylle
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32