I have an authentication script in ejabberd (XMPP server) that based off of THIS LINK
I have slightly modified the script so that instead of setting the variable out, it just returns true or false.
I'm using Ubuntu, MySQL, ejabberd, and Python.
I can authenticate all the records that are already on the database. But, when I add or remove records (I do this through phpMyAdmin), the script doesn't seem to know that the database has changed (I remove a user in phpMyAdmin and it still authenticates the user). The only time when the script recognizes the new records is when I restart or force-reload the ejabberd server. I've already been told its not a mySQL caching problem. I made sure I turned off external authentication caching for ejabberd.
That's all I can think of right now. I'll add more information if I can think of it. Any help is appreciated. I have no idea what is going on.
Addition: I turned on the MySQL logs, and all the queries there so there is not skipping queries.
I managed to fix this problem by changing the database engine back to MYISAM rather than INNODB. But I would like to know if this can be fixed for INNODB.
Edit: to fix it in innodb, set autocommit to true
Related
Everything worked great until today, while I did not change anything in the code.
I can't connect to the database not from the application, not from the IDE, did something go wrong on the heroku side? I have not seen news with global updates over the past couple of days on the heroku website. Can anyone advise how to solve the current problem?
I use the free version of dyno and postgresql, I definitely still have a lot of free space (less than 1 thousand fields). It looks like blocking access to the database locally, not from the service side.
What I would try in your situation:
Go to https://data.heroku.com/, select your Datastore and check everything there: Health, number of connections, number of rows, data size.
If everything is fine: Go to settings -> database credentials and try setting up a connection from any desktop tool such as Navicat or Pgadmin. What error message do you get?
Set-up another database on Heroku and try the same. If the second DB works, there is an issue with the first one. If it does not, it's rather about your setup/settings.
Hope that helps
I am building a web application in Flask.
We have opened up the database window of PyCharm and established a data source to a SQL server database.
My question is what does establishing a data source do?
Does is remove the need to connect to a database manually?, like for example
db = MySQLdb.connect("localhost","testuser","test123","TESTDB" )
If the answer is yes it does remove the need to set
updb = MySQLdb.connect("localhost","testuser","test123","TESTDB" )
then how can you access the data in the database, and establish a cursor object?
The JetBrains IDEs such as PyCharm or IntelliJ have a database browser, basically productionalized as it's own IDE called DataGrip, but that's besides the point.
Fact is, no, that doesn't replace the need for code, and you could have zero code and make a database connection, or entirely code and never touch the database window, ever (because you don't need PyCharm to write said code).
So, they are separate things, just like how "SQL Server" means something completely different from "MySQL" (e.g. you might need a different library)
I am writing a Python server in Tornado which works with HTML5 WebSockets. My server works by creating a connection with the client browser through JavaScript. Once a connection is created, it stays open until the browser (or the server closes it). I need to periodically check if one of my models has changed or if the database has updated.
Here's code example to demonstrate what I mean:
>>> mymodels = MyModel.objects.all()
>>> len(mymodels)
150
>>> # Some stuff happens on the client and the model is changed, one more entry is added
>>> mymodels = MyModel.objects.all()
>>> len(mymodels)
151
This all happens within a server application where the changes to the model will occur within one "session" of the server script running. Is there anyway I can check for new objects or refresh my Django database?
An example of what I mean if it still isn't clear: Let's say I have a model called MyModel. When the server script is first run, it has 150 different entries or database rows. I establish a WebSocket connection with my server from my client and request that I be updated whenever a new change occurs. Somewhere else in my client, some other user does something that creates a new row in my database for the MyModel class. My server, while still keeping the same connection that it has to the original client already, needs to be able to detect that change without stopping its execution.
Checking periodically isn't the problem, its actually making sure that the Django database API is aware of the newly added information. Is there anyway I can ensure that that happens? The originally posted example code does not actually work. The length of MyModel.objects.all() is still 150 no matter how many items I add to the model. If I restart my Django shell, it updates the count.
Some other things I have tried:
Reloading the models module using the built-in reload() function.
Filtering the model for a certain set of MyModel
Using raw SQL queries to both select everything and filter based on certain conditions
All of these methods keep returning the same number of MyModel objects no matter how many changes I make to the database. Interestingly enough, running the raw SQL in MySQL Workbench produces the expected results.
I FIGURED IT OUT!
The simplest way to force Django to update its database reference is to close the database connection. Django will automatically create a new one as it needs to.
django.db.close_connection()
If you have changes that need to be committed before you close the connection, this will accomplish the same as above, but keep the changes that you have made. (i.e. you will not need to close the connection as this refreshes the database anyway)
django.db.connection._commit()
Thanks for your comments and have a nice day!
If it's all within one "session" of the server-side script running, maybe you've got the whole thing running in one DB transaction (which would mean that nothing else could see it) - although the fact that you can see them incrementally in Workbench suggests not. Having said that, it's worth checking out what you're doing with transactions.
Also, have you read this to make sure that Django is doing what you think it's doing?
I am facing a problem where data from MySQL retrieved using PySQLPool is returned as the db was at start of process, INSERT or UPDATE queries from python or MySQL client do not show up until a kill and re-run of the python process.
Would appreciate any help regarding this.
Ref: Why are some mysql connections selecting old data the mysql database after a delete + insert?
MySQL's isolation level was causing this. Somehow only python clients get affected and never stumbled across this issue earlier. It is a valid problem and has a detailed solution. My question was targeting python and pySQLPool because it did not occur to me that MySQL could be the one causing this. Now my deployment procedure includes details on altering global isolation level for MySQL to be "READ-COMMITTED".
SET GLOBAL tx_isolation='READ-COMMITTED';
At work we have to use ClearQuest. Recently I have had the necessity of making some "complicated" queries and I have found that to be very difficult with the CQ query editor.
I have think about using python to connect directly to the database and make my own queries so I can run the script automagically, but I am unable to connect to the database.
I have follow the tip of this answer https://stackoverflow.com/a/1870849/156459
But without any success.
I have compared the cx_Oracle.makedsn return value with the one sent by the CQ client for windows and both are equal.
The error I get is "ORA-01017: Invalid username/password; logon denied" . I have double checked the user and password and are correct.
I have captured the TSN packets between the oracle server and my computer while running my script and I have seen something rare to me: My computer ask for a connection and the server answer with Accept ...
Any help would be ( very ) welcomed.
Thanks for your time!
Check whether your password contains any characters that require escaping.