Postgres data loss - python

We have an app hosted on Heroku. Recently, I witnessed data being lost from the postgres database. The app is made with django, and there are news articles. So I edited the title of an article and saved it. I could see that changes were saved in the django admin and on the site the corrected title appeared. But after a while, the old version of the title reappeared on the site. So I edited the title for the second time, and the same thing happened again. This time, it took sometime between 1 and 30 minutes for the old version to reappear.
I am completely confused to what might be happening here. There is no indication of any kind of error in the logs.
I asked Heroku support for assistance, but without being able to reproduce the error, they couldn't really do much.
This phenomenon happened twice. I'd like to understand it so if anyone has a theory, please share it.
Thanks!

Related

django query is slow, but my sql query is fast

I have a very simple vie in my django application
def notProjectsView(request):
context = {
'projects':notProject.objects.all(),
'title':'Not Projects | Dark White Studios'
}
return render(request, 'not-projects.html', context)
When I removed the context it ran fast, but it's a simple query and shouldn't be so long, the database also doesn't have a lot of records, it has 1 project and in the template I query project.notProjectImage.all which could cause an n+1 issue but I removed that part to test it and it was still slow
Django debug toobar shows a ~50ms sql query while the actual request in the time tab is over 15 seconds
So, you have eliminated the DB query as the reason it's slow. You need to look elsewhere. Is it slow when you test the view (using the Django test framework to GET html or POST data and check html response)? Then you've eliminated something happening in the browser, like a misbehaving script or framework. Which leaves the project's Python code, or something wrong with the machine it is running on. Is something looping far more than it ought to? Or is your developer machine page-thrashing because it is short of RAM?
(Oh, and where is the DB located? Developers usually host it on the machine they are developing with, but if it's cloud-based, look at the performance of the internet connection and possibly of the service itself).
Always work like Sherlock Holmes. "Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth."
BTW I recently traced occasional slowness on my developer machine to a bug in the (Cinnamon/Linux) GUI. That was of course the last place I though to look until I had eliminated absolutely everything else.

Connecting Two Websites with Coding

I am new to website development, my issue is figuring out what code I need to input so that my two website talk with one another. My two website are built similar to an Amazon platform. Where one site is for clients to input their content and the other site is for the consumer to browse and purchase. I have both built, but need to figure out what coding I need to input so that when a client enters new content or edits content it reflects on the consumer site.
Thank you for any advice or coding possibilities.
Elizabeth
I can't show you any code but you need something like a database. If The websites are basially on the same server and both are accessing to the same folders you could basically also use a normal file but i would recommend making a database. I dont really know much about databases but I am quite sure it should work. Have a look on youtube about how to work with databases. I think you need a bit knoweldge in JavaScript. Depending on the database you are gonna use you also need to know MySQL or rathe the language the database works with. I hope this helped you. If not just reply to this reply

xero_python Create Timesheet

I'm working off xero_python app example seen here and attempting to make a create_timesheet route.
So far I've not found any material on creating timesheets using xero_python.payrollau so wondering if anyone here might have some experience with this?
I've shared my current example as an issue for the above git. I keep hitting various hurdles such as timesheet ids not being accepted/etc.
If anyone has been successful with the above I would be super grateful for some guidance here.

Possible MySQL authentication issue with python package (PyMySQL3)

I actually found a blog post that pretty much sums up my problem. Its at
http://simon04.net/2013/03/python3-mysql/
The blog post is the most clear but to summarize: I'm currently trying to access a remote MySQL database with a python package called PyMySQL3. However I keep getting the error: "AttributeError: 'bytes' object has no attribute 'encode'". From the blog post above and some other research, I think this has to do with my database having an old authentication method.
However, I'm confused because it looks like the old authentication method was phased out sometime in MySQL 4.0. The database I have runs MySQL 5.0.51a. Shouldn't my database have the correct authentication?
I've been working on this awhile and getting a little frustrated. Hopefully someone can help. Thanks,
From https://github.com/petehunt/PyMySQL/issues/64
For me this problem was due to the usage of the old authentication
method (cf.
http://dev.mysql.com/doc/internals/en/authentication-method.html).
Creating a new user (resetting the password might work as well) and
making sure that the password column for this user in the mysql.user
table starts with a * (otherwise check the server configuration
according to the above link), solved the problem for me.
Have you created the users with this very Version you mentioned?
The thread shows how to fix the problem in the code aswell, tellme when you need additional help to fix it. I would edit my answer accordingly.
Ok, while investigating this more I thought that maybe my hosting company (aplus.net) just wasn't up to date. I was going to switch companies anyways and so I opened a new account with another company. Now I have no problems connecting with PyMySQL3. So apparently, my old hosting company just wasn't up to date or at least their sql configuration was breaking PyMySQL3.
Thanks for your reponse though. Hopefully not many other people have this issue because switching hosting companies isn't always the best answer =O

Simple API's to play around with for Python/Django?

Does anyone know of simple and well documented API's with plenty of hand holding examples that assumes very little or no prior knowledge of web development?
I've been messing around with Pyfacebook and Facebook-Python-SDK in trying to create a simple photo display app but I haven't been able to make much headway after spending the last few days on it. The main reason for this is simply because I just wasn't able to find a good tutorial that walks me through all the steps. So, I'm putting this mini project on pause and looking for lower hanging fruit.
In terms of skill level, I'm pretty ok on the basics of Python and Django.
Update
I've done the tutorials at http://www.djangoproject.com/ already. Really looking for ideas and suggestions on webapp projects that utilises an API. E.g, a twitter app that displays a user's most frequently used keywords in a tagcloud.
Update2
Side note: Having mess around with Twitter's API for a little bit, I would definitely recommend to start with Twitter first as opposed to Facebook. It's easier and better documented.
Best place to start is with tutorials on djangoproject.com.
Have you tried the Django tutorial? It is pretty basic, but touches on all important points required to develop your own basic app.
django-basic-apps contains a collection of apps you might enjoy reading.
Edit: Check out this good list of web services I found. :)
As far as I know you can't write facebook apps with Django. Facebook uses their own API and stuff. They are completely different.
And for the twitter API thingy I have an idea.
Develop a django app which can used to
scrap and backup tweets.
The scenario is during any FOSS
conference, they are using a #hastag
to identify tweets related to that
conf. But after sometime these tweets
don't show up even on search. For
example we used #inpycon2010 tag for
Pycon conf in India. But now when I
search for this tag, nothing shows up.
So what you can do allow users to
register a hastag and set a time
interval. Within that time interval
your app should scrap all the tweets
and backup them. The user should be
able to retreive from that later.
If you start this a foss project, I'm ready to jump in :)

Categories