From thiemo.theile at slf.ch Fri Feb 8 10:49:07 2019 From: thiemo.theile at slf.ch (thiemo.theile at slf.ch) Date: Fri, 8 Feb 2019 16:49:07 +0100 Subject: [python-win32] problem with cython on windows Message-ID: I try to write a python wrapper for a c++-library ( https://models.slf.ch/p/meteoio/ ) using cython. Everything works fine on linux. Also with python "Microsoft Visual C++ Compiler for Python 2.7" it works fine. The trouble starts with Visual Studio 2017 and python 3.x. The module builds fine. But when running the module I get strange crashes. Some functions form the module are working, some are not. Did someone experience similar problems or has an idea what could be wrong? -------------- next part -------------- An HTML attachment was scrubbed... URL: From niki at vintech.bg Mon Feb 11 01:11:26 2019 From: niki at vintech.bg (Nikolai Spahiev) Date: Mon, 11 Feb 2019 08:11:26 +0200 (EET) Subject: [python-win32] problem with cython on windows In-Reply-To: References: Message-ID: <1746366880.8478.1549865486459.JavaMail.zimbra@vintech.bg> From: "thiemo theile" To: python-win32 at python.org Sent: Friday, February 8, 2019 6:49:07 PM Subject: [python-win32] problem with cython on windows I try to write a python wrapper for a c++-library ( [ https://models.slf.ch/p/meteoio/ | https://models.slf.ch/p/meteoio/ ] ) using cython. Everything works fine on linux. Also with python "Microsoft Visual C++ Compiler for Python 2.7" it works fine. The trouble starts with Visual Studio 2017 and python 3.x. The module builds fine. But when running the module I get strange crashes. Some functions form the module are working, some are not. Did someone experience similar problems or has an idea what could be wrong? With C++ mixing compilers is almost impossible. Do you compule *ALL* sources with same compiler? HTH Niki -------------- next part -------------- An HTML attachment was scrubbed... URL: From niki at vintech.bg Tue Feb 12 04:04:47 2019 From: niki at vintech.bg (Nikolai Spahiev) Date: Tue, 12 Feb 2019 11:04:47 +0200 (EET) Subject: [python-win32] python-win32 Digest, Vol 190, Issue 2 In-Reply-To: References: Message-ID: <1492387141.10271.1549962287727.JavaMail.zimbra@vintech.bg> From: "thiemo theile" Yes, I compiled all the sources with the same compiler. At least every source code which is part of the meteoio-library. What do you mean by "ALL sources"? Here is what I do: -generate the project with cmake setting "generator" to "Visual Studio 15 2017" and "inheritEnvironments" to "msvc_x86". Then build the dll (libmeteoio.dll). -run setup.py with python3.7_32bit. setuptools automatically finds the correct compiler (Visual Studio 2015) and builds the wrapper (pyd-file) -alternatively I can add all the source files to my setup.py (instead of using the dll). the wrapper also builds fine. but I get the same crashes when using the wrapper in a python script. I always add all source files to setup.py because distutils set compiler flags compatible with python runtime DLL. If the C++ project needs specific C++ flags, they can be set in setup.py Niki -------------- next part -------------- An HTML attachment was scrubbed... URL: From thiemo.theile at slf.ch Tue Feb 12 02:52:31 2019 From: thiemo.theile at slf.ch (thiemo.theile at slf.ch) Date: Tue, 12 Feb 2019 08:52:31 +0100 Subject: [python-win32] python-win32 Digest, Vol 190, Issue 2 In-Reply-To: References: Message-ID: Yes, I compiled all the sources with the same compiler. At least every source code which is part of the meteoio-library. What do you mean by "ALL sources"? Here is what I do: -generate the project with cmake setting "generator" to "Visual Studio 15 2017" and "inheritEnvironments" to "msvc_x86". Then build the dll (libmeteoio.dll). -run setup.py with python3.7_32bit. setuptools automatically finds the correct compiler (Visual Studio 2015) and builds the wrapper (pyd-file) -alternatively I can add all the source files to my setup.py (instead of using the dll). the wrapper also builds fine. but I get the same crashes when using the wrapper in a python script. From: python-win32-request at python.org To: python-win32 at python.org Date: 11.02.2019 18:02 Subject: python-win32 Digest, Vol 190, Issue 2 Sent by: "python-win32" Send python-win32 mailing list submissions to python-win32 at python.org To subscribe or unsubscribe via the World Wide Web, visit https://mail.python.org/mailman/listinfo/python-win32 or, via email, send a message with subject or body 'help' to python-win32-request at python.org You can reach the person managing the list at python-win32-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of python-win32 digest..." Today's Topics: 1. Re: problem with cython on windows (Nikolai Spahiev) ---------------------------------------------------------------------- Message: 1 Date: Mon, 11 Feb 2019 08:11:26 +0200 (EET) From: Nikolai Spahiev Cc: python-win32 at python.org Subject: Re: [python-win32] problem with cython on windows Message-ID: <1746366880.8478.1549865486459.JavaMail.zimbra at vintech.bg> Content-Type: text/plain; charset="utf-8" From: "thiemo theile" To: python-win32 at python.org Sent: Friday, February 8, 2019 6:49:07 PM Subject: [python-win32] problem with cython on windows I try to write a python wrapper for a c++-library ( [ https://models.slf.ch/p/meteoio/ | https://models.slf.ch/p/meteoio/ ] ) using cython. Everything works fine on linux. Also with python "Microsoft Visual C++ Compiler for Python 2.7" it works fine. The trouble starts with Visual Studio 2017 and python 3.x. The module builds fine. But when running the module I get strange crashes. Some functions form the module are working, some are not. Did someone experience similar problems or has an idea what could be wrong? With C++ mixing compilers is almost impossible. Do you compule *ALL* sources with same compiler? HTH Niki -------------- next part -------------- An HTML attachment was scrubbed... URL: < http://mail.python.org/pipermail/python-win32/attachments/20190211/baa76970/attachment-0001.html > ------------------------------ Subject: Digest Footer _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 ------------------------------ End of python-win32 Digest, Vol 190, Issue 2 ******************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From thiemo.theile at slf.ch Tue Feb 12 05:10:48 2019 From: thiemo.theile at slf.ch (thiemo.theile at slf.ch) Date: Tue, 12 Feb 2019 11:10:48 +0100 Subject: [python-win32] python-win32 Digest, Vol 190, Issue 2 In-Reply-To: <1492387141.10271.1549962287727.JavaMail.zimbra@vintech.bg> References: <1492387141.10271.1549962287727.JavaMail.zimbra@vintech.bg> Message-ID: Do you have a windows-system with a c-compiler and python installed? Could you run my cython-code? It would be very nice, if you could test if you get the same error or if something is wrong with my compiler-python-combination... Here a link to my project: https://www.dropbox.com/sh/fa090glkb4uko3i/AADD3DFqV6YFaZQiaA4y2cm1a?dl=0 To build the wrapper: -go to the subfolder "pythonWrapper" and execute: python.exe setupWinNoDLL.py build_ext --inplace To test the wrapper: -python.exe test.py For me the building of the wrapper works. But the test crashes. Thiemo From: "Nikolai Spahiev" To: "thiemo theile" Cc: "python-win32" Date: 12.02.2019 10:05 Subject: Re: python-win32 Digest, Vol 190, Issue 2 From: "thiemo theile" Yes, I compiled all the sources with the same compiler. At least every source code which is part of the meteoio-library. What do you mean by "ALL sources"? Here is what I do: -generate the project with cmake setting "generator" to "Visual Studio 15 2017" and "inheritEnvironments" to "msvc_x86". Then build the dll (libmeteoio.dll). -run setup.py with python3.7_32bit. setuptools automatically finds the correct compiler (Visual Studio 2015) and builds the wrapper (pyd-file) -alternatively I can add all the source files to my setup.py (instead of using the dll). the wrapper also builds fine. but I get the same crashes when using the wrapper in a python script. I always add all source files to setup.py because distutils set compiler flags compatible with python runtime DLL. If the C++ project needs specific C++ flags, they can be set in setup.py Niki -------------- next part -------------- An HTML attachment was scrubbed... URL: From maikon_abati at hotmail.com Fri Feb 15 07:41:42 2019 From: maikon_abati at hotmail.com (Maikon Abati) Date: Fri, 15 Feb 2019 12:41:42 +0000 Subject: [python-win32] Excel.Application for SaveAsODC. Message-ID: Hello! I need get data of PivotCaches to ODC File, but a have the following error: --------------------------------------------------------------------------- com_error Traceback (most recent call last) in 5 print(odc_name) 6 ----> 7 nivel_1.SaveAsODC(ODCFileName=odc_name) c:\users\mdabati\appdata\local\programs\python\python36\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x9\PivotCache.py in SaveAsODC(self, ODCFileName, Description, Keywords) 59 def SaveAsODC(self, ODCFileName=defaultNamedNotOptArg, Description=defaultNamedOptArg, Keywords=defaultNamedOptArg): 60 return self._oleobj_.InvokeTypes(2082, LCID, 1, (24, 0), ((8, 1), (12, 17), (12, 17)),ODCFileName ---> 61 , Description, Keywords) 62 63 _prop_map_get_ = { com_error: (-2147352567, 'Exce??o.', (0, None, None, None, 0, -2147024809), None) I'm use Python 3.65, my code: import urllib import pandas as pd import random import win32com.client Excel = win32com.client.gencache.EnsureDispatch('Excel.Application') # URL file url = 'http://www.anp.gov.br/images/DADOS_ESTATISTICOS/Vendas_de_Combustiveis/Vendas_de_Combustiveis_m3.xls' # Load URL file_name, headers = urllib.request.urlretrieve(url) # Load XLS arq = Excel.Workbooks.Open(file_name) PivotCaches = arq.PivotCaches() for nivel_1 in PivotCaches.__iter__(): odc_name = 'ODCFile_'+str(random.randint(1,100)) print(odc_name) nivel_1.SaveAsODC(ODCFileName=odc_name) Att. Maikon Abati -------------- next part -------------- An HTML attachment was scrubbed... URL: From nulla.epistola at web.de Wed Feb 20 11:22:16 2019 From: nulla.epistola at web.de (Sibylle Koczian) Date: Wed, 20 Feb 2019 17:22:16 +0100 Subject: [python-win32] adodbapi: paramstyle 'named' doesn't work as expected Message-ID: Hello, I'm trying to write a small application to work with a Microsoft Access database. This application will have to insert and update records, and I'd like to use paramstyle='named'. With INSERT commands this seems to work, with UPDATE I get an exception I can't explain. Example: The database table called tblHaupt contains the fields id (integer, primary key, autoincrement), item (varchar), ort (integer, foreign key into another table). There are more fields, but the UPDATE command I've been trying out only uses these three. Code to try it: ######################################################################## import adodbapi CONNFORM = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};" DBLOKAL = r"X:\Path\to\database\db.accdb" # or db.mdb UPCMD = "UPDATE tblHaupt SET item = :item, ort = :ort_id WHERE id = :h_id" updata = {"item": "Testkeks D", "ort_id": 12, "h_id": 745} connstr = CONNFORM.format(DBLOKAL) conn = adodbapi.connect(connstr, paramstyle='named') curs = conn.cursor() curs.execute(UPCMD, updata) Result: Traceback (most recent call last): Python Shell, prompt 62, line 1 # Used internally for debug sandbox under external interpreter File "C:\Program Files\Python37\Lib\site-packages\adodbapi\adodbapi.py", line 867, in execute operation = self._reformat_operation(operation, parameters) # if 'named' will set self._parameter_names File "C:\Program Files\Python37\Lib\site-packages\adodbapi\adodbapi.py", line 751, in _reformat_operation operation, self._parameter_names = api.changeNamedToQmark(operation) # convert :name to ? File "C:\Program Files\Python37\Lib\site-packages\adodbapi\apibase.py", line 598, in changeNamedToQmark c = chunk[i] builtins.IndexError: string index out of range ########################################################################## What's the matter here? INSERT into the same table works. The same UPDATE command using paramstyle 'pyformat' works. Why not UPDATE with 'named'? Is something wrong with my parameter dictionary and I don't see it? Python version is 3.7.2 (64bit), adodbapi.__version__ = 2.6.0.6, Windows 10 Home, Version 1809 (64bit). Thank you for explanations, Sibylle From timr at probo.com Wed Feb 20 14:00:48 2019 From: timr at probo.com (Tim Roberts) Date: Wed, 20 Feb 2019 11:00:48 -0800 Subject: [python-win32] adodbapi: paramstyle 'named' doesn't work as expected In-Reply-To: References: Message-ID: Dennis Lee Bieber wrote: > > The loop is looking for the end of the parameter name by looking for a > non-alphanumeric character. But your update command just... ends -- there > is no non-alphanumeric character after the name to terminate the loop. > INSERT syntax has a closing ) to terminate. > > I WOULD consider this a subtle bug in the ADODBAPI code. You are being too kind.? This bug is not subtle in any way. Python is so good at string parsing -- there must be a better way to write that. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3980 bytes Desc: S/MIME Cryptographic Signature URL: From nulla.epistola at web.de Thu Feb 21 08:15:40 2019 From: nulla.epistola at web.de (Sibylle Koczian) Date: Thu, 21 Feb 2019 14:15:40 +0100 Subject: [python-win32] adodbapi: paramstyle 'named' doesn't work as expected In-Reply-To: References: Message-ID: <604046a2-0b39-1673-b22d-d50529d1a8d8@web.de> Am 20.02.2019 um 19:28 schrieb Dennis Lee Bieber: > On Wed, 20 Feb 2019 17:22:16 +0100, Sibylle Koczian > declaimed the following: > >> >> UPCMD = "UPDATE tblHaupt SET item = :item, ort = :ort_id WHERE id = :h_id" > > As a total wild guess... try ending the SQL with a ; or space > > ... :h_id;" > or > ... :h_id " > That "wild guess" was exactly right. After adding ; or space to my update command my test script finished as expected. After removing the closing ORDER BY clause from a SELECT the IndexError appeared at the execution of that command. I'd think that SQL statements ending with a :name parameter can't be that unusual, especially UPDATE and probably DELETE. But possibly the "named" paramstyle isn't much used. Thank you very much, Sibylle From nulla.epistola at web.de Sat Feb 23 09:24:07 2019 From: nulla.epistola at web.de (Sibylle Koczian) Date: Sat, 23 Feb 2019 15:24:07 +0100 Subject: [python-win32] adodbapi: paramstyle 'named' doesn't work as expected In-Reply-To: References: <604046a2-0b39-1673-b22d-d50529d1a8d8@web.de> Message-ID: <571efba6-bb11-e85c-3a8a-600f283b71a6@web.de> Am 21.02.2019 um 16:26 schrieb Dennis Lee Bieber: > > If I were coding something, I'd likely use the native style to reduce > the cost of conversion overhead. Relatively speaking, that name extraction > code is /slow/ -- it splits the query on :, then loops over each character > looking for something (non-alphanumeric and not _) on which to terminate > the resulting name... and that loop is done at Python source code level (it > doesn't even use a > > for i,c in enumerate(chunk): > > which would exit the loop on the end of the chunk; instead it manually > increments the counter to be "next character" [which fails when there is no > next character]. > > Well - I started to write my application without much thought about execution speed, because the database tables concerned are small to very small. If I can use a dictionary for query parameters then the function producing the parameters doesn't need to know much about the SQL query using them. That's why I like pyformat and named. Looking at the apibase code I think pyformat might be a little bit faster? But when I saw things didn't work as expected that had to be cleared up in any case. Greetings Sibylle From vernondcole at gmail.com Mon Feb 25 03:20:31 2019 From: vernondcole at gmail.com (Vernon D. Cole) Date: Mon, 25 Feb 2019 01:20:31 -0700 Subject: [python-win32] adodbapi: paramstyle 'named' doesn't work as expected In-Reply-To: <571efba6-bb11-e85c-3a8a-600f283b71a6@web.de> References: <604046a2-0b39-1673-b22d-d50529d1a8d8@web.de> <571efba6-bb11-e85c-3a8a-600f283b71a6@web.de> Message-ID: Sibyille: Thanks for the report and the excellent analysis. I was afraid no one would ever use "named" paramstyle. Dennis: Any code suggestion would be very welcome. Would you be able to suggest a patch? -- Vernon Cole On Sat, Feb 23, 2019 at 7:30 AM Sibylle Koczian wrote: > Am 21.02.2019 um 16:26 schrieb Dennis Lee Bieber: > > > > If I were coding something, I'd likely use the native style to > reduce > > the cost of conversion overhead. Relatively speaking, that name > extraction > > code is /slow/ -- it splits the query on :, then loops over each > character > > looking for something (non-alphanumeric and not _) on which to terminate > > the resulting name... and that loop is done at Python source code level > (it > > doesn't even use a > > > > for i,c in enumerate(chunk): > > > > which would exit the loop on the end of the chunk; instead it manually > > increments the counter to be "next character" [which fails when there is > no > > next character]. > > > > > > Well - I started to write my application without much thought about > execution speed, because the database tables concerned are small to very > small. If I can use a dictionary for query parameters then the function > producing the parameters doesn't need to know much about the SQL query > using them. That's why I like pyformat and named. Looking at the apibase > code I think pyformat might be a little bit faster? > > But when I saw things didn't work as expected that had to be cleared up > in any case. > > Greetings > Sibylle > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: