I'm writing a Python app and I want to test some triggers I have on a postgres db. I've used testing.postgresql in the past for storing simple things. Does it support triggers? I'm running migrations against it and the triggers don't seem to react (or exist if I look in information_schema.triggers).
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.
Right now I have a django website. I manage to programmatically populate the database using django commands and everything works fine.
I now want to have a dedicated server for populating the database programmatically but I do not want to give up using django commands as thei are very powerful in my opinion.
I am using aws elastic beanstalk and an rds db instance, so I know that I could simply create my scripts (the ones I use to populate the db) in pure python, but I am wondering if there is a nice way to do the same using Django.
I thought of simply setting up a new Django project that connects to the same RDS database, but this would mean that I need to copy all the models/settings every time a make a change to my main website... I did not really seem ideal.
Any thoughts?
I am trying to debug a Pootle (pootle is build on django) installation which fails with a django transaction error whenever I try to add a template to an existing language. Using the python debugger I can see that it fails when pootle tries to save a model as well as all the queries that have been made in that session.
What I can't see is what specifically causes the save to fail. I figure pootle/django must have added some database database constraint, how do I figure out which one? MySql (the database being used) apparently can't log just failed transactions.
Install django debug toolbar, you can easily check all of the queries that have been executed
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 had a django project with one database (default). South was installed for generating migration scripts and nose as a test framework. Models were built on this database. All tests were run successfully.
Subsequently, I needed to connect a second database (legacy), which I also added to the DATABASES configuration. I access this database using raw sql and no models. While trying to run the previously running tests, I noticed that:
nose also creates a test database for the legacy database
default django tables (auth_... etc) are also created in this database
south runs all migration scripts against the legacy database as well and fail to do so
What I would like is to disable the creation of the test legacy database and the running of the migration scripts on it. Ideally, I would like to create tables in the test legacy database myself by issuing raw sql create-insert statements. Is that possible?
Thank you for any help.
Your path of least resistance is probably to write your own test running management command. To do so you can either override the existing command or simply create a separate command with your desired behavior.
The docs for creating custom management commands can be found on the official django docs and you can find a decent example of overriding the stock "test" command in the django-test-extensions project.