I have a desire to call the python script from the mysql query.
like we call the procedure in mysql : call procedurename();
just like as above is there any way in mysql to call external scripts like ,
call script(somefile.py)
i wrote the above thing to explain the exactly what i want.
This does not seem to be possible in MySQL, for security reasons. You can have a look at this related question Executing shell command from MySQL. You can however do this in other database like oracle. In Postgresql there is also support to create python stored procedures in the database. You could use this technique to have your database triggers run python code.
Related
I would like to keep the django server running as I call some custom commands that will read / write to the sqlite DB. However I'm nervous that this may conflict due to the main server locking the database file.
Is this cause for concern ?
I can't use PostgreSQL or MySQL.
I tried this and it didn't throw any errors, however I would like to know if this is something that can occur.
I want to give my python program which uses postgresql as database to another person without them having the fuzz of installing postgresql themselves.
Is there a way of doing that without switching to sqlite?
Basically i'm developing an application in python where it listens to external sqlite database changes, so far i implemented update_hook()(from this example: SQLite Data Change Notification Callbacks in Python or Bash or CLI) it worked well when i launch SQL statements in the same process however when i use external database that has now relation with my process it doesn't work.
My question is how do i listen to database changes from an external process(A) that has no relation with process(B).
SQLite has no mechanism by which another process can be notified.
You have to implement some communication mechanism outside of SQLite.
im working on python application that requiring database connections..I had developed my application with sqlite3 but it start showing the error(the database is locked).. so I decided to use MySQL database instead.. and it is pretty good with no error..
the only one problem is that I need to ask every user using my application to install MySQL server on his pc (appserv for example) ..
so can I make mysql to be like sqlite3 apart of python lib. so I can produce a python script can be converted into exe file by the tool pyInstaller.exe and no need to install mysql server by users???
update:
after reviewing the code I found opened connection not closed correctly and work fine with sqllite3 ..thank you every body
It depends (more "depends" in the answer).
If you need to share the data between the users of your application - you need a mysql database server somewhere setup, your application would need to have an access to it. And, the performance can really depend on the network - depends on how heavily would the application use the database. The application itself would only need to know how to "speak" with the database server - python mysql driver, like MySQLdb or pymysql.
If you don't need to share the data between users - then sqlite may be an option. Or may be not - depends on what do you want to store there, what for and what do you need to do with the data.
So, more questions than answers, probably it was more suitable for a comment. At least, think about what I've said.
Also see:
https://stackoverflow.com/questions/1009438/which-database-should-i-use-for-my-desktop-application
Python Desktop Application Database
Python Framework for Desktop Database Application
Hope that helps.
If your application is a stand-alone system such that each user maintains their own private database then you have no alternative to install MySQL on each system that is running the application. You cannot bundle MySQL into your application such that it does not require a separate installation.
There is an embedded version of MySQL that you can build into your application (thanks, Carsten, in the comments, for pointing this out). More information is here: http://mysql-python.blogspot.com/. It may take some effort to get this working (on Windows you apparently need to build it from source code) and will take some more work to get it packaged up when you generate your executable, but this might be a MySQL solution for you.
I've just finished updating a web application using SQLite which had begun reporting Database is locked errors as the usage scaled up. By rewriting the database code with care I was able to produce a system that can handle moderate to heavy usage (in the context of a 15 person company) reliably still using SQLite -- you have to be careful to keep your connections around for the minimum time necessary and always call .close() on them. If your application is really single-user you should have no problem supporting it using SQLite -- and that's doubly true if it's single-threaded.
I am able to execute the chat and similar basic Python projects with
the command prompt, though I do not know yet how to execute a project
with an SQL database.
Can somebody suggest me a way to open the SQL file schema.sql so I can
have a look at the blog demo?
I am using Python 2.7 with the recent version of Tornado on Windows 7
p.s.
I do understand now that the SQL file is just text with SQL commands and I simply could copy and paste it, though I also see that the CREATE DATABASE command is commented out in the file so I would have to add that one too.
I am wondering which way would be good to achieve this?
I can tell by the blog.py file (when I open it) that the database connection happens to a MySQL database, thus I would not be able to use SQLite or similar.
Though I have XAMPP installed would that work? Remember that XAMPP runs on Apache while the blog demo runs on the Tornado server. Would this constellation work out properly?
If you have XAMPP running, the easiest for you would be to go in Php My Admin (http://localhost/phpmyadmin). Then, in the SQL tab, copy-paste the SQL file you want and press OK.
Just run the Tornado server then, and it should work fine.