I use the sqlite3 librairy on python to interact with a .db file.
With this request:
SELECT * FROM LesFilms F JOIN LesRealisateurs R ON (F.film_id=R.film_id) WHERE realisateur="Tim Burtyn" or soundex("Tim Burtyn")=soundex(R.realisateur) or realisateur like"T%m Burtyn" or realisateur like"Tim B%rtyn" or realisateur like"Tim Burt%n";
I got this error:
sqlite3.OperationalError: no such function: soundex
Do someone already face this problem? I share the whole request in case, I'm a total beginner.
Thank you,
Elias
I think you are out of luck, as you have probably gathered from the comments. The Python standard library module sqlite3 generally provides an up-to-date version of sqlite.
In Python 3.9 it is 3.32.3 from June 2020.
In Python 3.8 it is 3.31.1 from January 2020.
In Python 3.7 and Python 2.7.17 it is 3.28.0 from April 2019.
But the Python sqlite3 library does not provide optional sqlite features that come switched off by default. This includes the soundex function. I can't recommend that you try building your own version of the Python standard library module with the option switched on. That sort of thing is best left to Python implementers.
As an alternative you might try the levenshtein module: pip install python-Levenshtein or the metaphone module: pip install Metaphone.
To use either you would need to fetch more records from the database than you really want, for example where realisateur like "T%" and then discard the mismatches in Python code rather than in the where clause.
This is not as bad as it sounds, and may have benefits. Soundex was developed in the early 20th century and so it was intended for people to be able to compute it quickly by hand. It has significant deficiencies, as shown by the many attempts in the subsequent 100 years to improve it. The primary reason for its popularity is because it is provided by many SQL implementations, not because it is particularly good.
load your data into a dataframe then use fuzzywuzzy to find similar string words
Related
Whenever i try to pip install pyleargist, it gives me this issue.
Is there a version compatible with python 3 ?
Can someone help on this ?
The library was last updated in 2012, see the pypi page and as you already noticed, the issue you are seeing is based on the fact that it was written for python 2. In this case, file seems to be used in the setup.py, which was removed in python3. For this exact library, it seems to be stale, so no other versions.
You have two options:
It does not look to be a large library, you could download the source code from pypi and try to fix the python 2/3 issues.
Search for another library. A google search shows several options for python libraries that can compute the GIST descriptor. Just look for another one that fits your requirements
Which Python build was up to date during 1999? I'm trying to run module files through the python interpreter, and the example in the book doesn't read the same syntax as the print command works for Python 3.5. What syntax should I use running module files during the Python 3.5 Build.
According to Wikipedia (History of Python), Python 1.5 or 1.6 would be your best bet; though I would probably recommend finding a more current book (or online resource) if possible, since learning an obsolete version of the language won't be very useful (you'll have to find old versions of every library you want to use) and may cause you headaches in the future when you want to learn the new syntax.
I'd like to upgrade to python 3.5, but I use legacy python 2.7 packages. Is it easy to run legacy packages in python 3.5? I have been under the impression that this isn't easy, but I did a few searches to see if I'm wrong and didn't come up with much.
I would expect there to be a multiprocessing package that allows standardized hand-offs between 3.5 code and 2.7 packages, allowing them to run independently under their own environments, but being somewhat seamless to the developer.
I'm not talking about converting my own code to 3.5, I'm talking about libraries that I use that won't be updated for or by me.
If you used the newer syntax supported by 2.7, e.g. around exceptions, and/or, better yet, worked with new features imported from __future__, you'll have much easier time converting your code to Python 3 (up to no changes at all). I'd suggest to follow this path first, for it can be trod gradually, without an abrupt jump to Python 3.
I suppose Python processes with different versions can interoperate, because object pickling format is compatible, and you can explicitly use a specific pickling protocol version on both sides to ensure that. I don't think multiprocessing packages on either side would be too useful, though. Consider using e.g. ZeroMQ as a more general solution.
Unfortunately there is no "nice" or automatic way of handling the processing of 2.7 code under 3.5 (that works perfectly).
You mentioned that you are concerned about libraries, not your own code - firstly, you'd hope that if they are under active development, they will be updated. If not, as you stated, then there is a possibility that they were written to be future proof. I've found some good ones are (e.g. google-api-python-client, e.g. https://github.com/google/google-api-python-client/blob/master/setup.py).
Failing that, the only way to upgrade is to fix all the syntax changes yourself. Most common ones I deal with are around 'print' and exception handling.
I am trying to run a Python program, written around 2001. I cant get it to run because a lot of the function s aren't recognised.
My best guess is that this is because the program was written using the scientific python modules based on the now deprecated numerical python, rather than its successor, numpy. I have been able to download the old numerical python, but I can't find old scientific python modules, only later ones based on numpy.
Does anyone know where I can download the old scientific python modules based on the deprecated numerical python?
Thanks
Mark
Here is a link to an old version from 2003.
You might also have to get a different python interpreter as well. Good luck!
I'm using a linux machine to make a little python program that needs to input its result in a SQL Server 2000 DB.
I'm new to python so I'm struggling quite a bit to find what's the best solution to connect to the DB using python 3, since most of the libs I looked only work in python 2.
As an added bonus question, the finished version of this will be compiled to a windows program using py2exe. Is there anything I should be aware of, any changes to make?
Thanks
One option would be trying the pyodbc branch for python 3 support. I think some people have reported success, but you might want to inquire at the pyodbc discussion group.
If you stick to platform independent parts of the python library (most of it), you shouldn't have any issues on windows with py2exe.
I can't answer your question directly, but given that many popular Python packages and frameworks are not yet fully supported on Python 3, you might consider just using Python 2.x. Unless there are features you absolutely cannot live without in Python 3, of course.
And it isn't clear from your post if you plan to deploy to Windows only, or Windows and Linux. If it's only Windows, then you should probably just develop on Windows to start with: the native MSSQL drivers are included in most recent versions so you don't have anything extra to install, and it gives you more options, such as adodbapi.
If you want to have portable mssql server library, you can try the module from www.pytds.com. It works with 2.5+ AND 3.1, have a good stored procedure support. It's api is more "functional", and has some good features you won't find anywhere else.