Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
MySQL in pythonista
-
Thnx .. I'll give that a shot ! I'm using 2.7 so if that worked for you hopefully it will be the same for me.
-
If it's not working and you're using Pythonista 3, try putting the scripts in the site-packages-2 folder instead. It's for modules that don't work with Python 3.x (mysqldb might be compatible, but I'm not sure).
Here's a quick example using INSERT:
import mysqldb db = mysqldb.connect(host= "mysql.my_domain.co.uk", user = "my_username", passwd="my_password", db="my_database", port = 3306) c = db.cursor() c.execute("INSERT INTO my_table (my_column1, my_column_2) VALUES (%s, %s)", (my_value_1, my_value_2)) db.commit() db.disconnect()
And another using SELECT:
import mysqldb db = mysqldb.connect(host= "mysql.my_domain.co.uk", user = "my_username", passwd="my_password", db="my_database", port = 3306) c = db.cursor() c.execute("SELECT * FROM my_table ORDER BY my_column_1 DESC LIMIT 0, 100") my_variable = c.fetchall() db.disconnect()
-
I got it working ! Thanks for your help chriswilson !
-
Is there an easier way to import the scripts from GitHub - or did you just create new files and copy - paste from safari or something?
Thanks!
-
Try the following in stash
git clone https://github.com/tommasoturchi/mysql-connector-pythonista.git
-
thank you so much! I tried git pull before asking you! I need to learn to use github thats for sure :)
Thanks again!
-
It worked with the files moved to: \Modules & Templates\site-packages-3
Thank you guys!This app together with the service provided by PythonAnywhere are so amazing! They changed my life for the better :)
Edit: Actually with the files moved to site-packages-3 - I get an error in connection.py. So I think mysqldb doesn't support python 3.
So I moved the files to site-packages-2 - and I tried running the script with python 2.7 - but the script just hangs with these two lines:import mysqldb
db = mysqldb.connect(host= "mysql.my_domain.co.uk", user = "my_username", passwd="my_password", db="my_database", port = 3306)
-
Actually it didn't just hang, it would eventually raise this error: ImportError: No localization support for language 'eng'.
It's probably a connection issue - but mysqldb doesn't raises the correct exception because he is looking for some file somewhere. Anyone have any clue?
-
No localization support for language 'eng'.
This might be related to https://github.com/omz/Pythonista-Issues/issues/27
-
I tried adding:
import locale locale.setlocale(locale.LC_ALL, 'de_DE')
as they said - but I just get 'unsupported locale setting'
-
Thank you for the magnificent problem-solving information. Allow me to submit the following step-by-step instructions for installing MySQL access to pythonista for iOS; it worked for me.
https://mysql.wisborg.dk/2018/08/31/mysql-connector-python-on-ios-using-pythonista-3/