I'm working with a leveldb database (the leveldb wrapper, not plyvel); I ran a few test Put/Get/Delete operations on the database and everything was okay. (If it's relevant, I was accessing the database from 2 separate Python scripts.) Then I tried to make another database within a Python file that was already accessing the first database and I got this error:
leveldb.LevelDBError: IO error: lock ./states/LOCK: already held by process
So far I've tried deleting the database, uninstalling and reinstalling leveldb, deleting the LOCK file within the database, restarting my computer, and whatever this code snippet is. I'm kind of at my wits' end now; any advice you can offer would be greatly appreciated. Thanks.
per design, leveldb databases can only be held open by a single process at the time.
Related
Hello I am creating a small program on Python with the cx_oracle module which allows me to connect to my Oracle database on my Computer. However I would like to send it to a friend and therefore I would like him to be able to handle the same database as me. So I thought of an embeddable database (a bit like a file on SQLite) but with Oracle I did not find such a possibility. I would like to know if there is a way to do it with Oracle or if I am forced to connect to a local database.
First of all, you can export and import Oracle databases, which would help you a lot at the initial sharing. However, if you share your database with a friend and both of you are working on the same database but with different copies, then the two databases will eventually diverge from each other, with ever greater impact. So, you will need to consider your options carefully:
Using a central server
You could use a central server (which could be a remote server or even your computer if you apply port forwarding), ensure that both you and your friend are connected to that database and then both your and his changes will automatically be applied to the same database, without copies.
Versioned dumps
You could use a versioning tool, like git to store the versions of your database dump/structure/data and both you and your friend could use this, maybe storing the versions in a central repositories, so you would not need to send and communicate your database changes again and again. This would ensure schema and data synchronization, albeit you will have frequent merge conflicts and other merge-related problems.
Versioned scripts
You and your friend could write versioned scripts. This would apply on structural changes, so your and your friend's test data would diverge, but the structure would not.
Migration scripts
Some ORMs have automatically generated migration scripts and one can go forwards or backwards some levels. I do not particularly like the idea of automatically generated change scripts, but it is certainly a possible solution.
I wrote a Python 2.7 script based on the Python examples from google Adwords on github, installed the MySQL Connector from MySQL Page itself under Connectors.
And started with creating the script, but I am not able to find the bug which is causing that MySQL stops insert data or not even goes into the function.
No error messages, even removed all try and catch. Same.
If you like to check it for yourself: http://pastebin.com/WEQqBNHB
I used 5 Connections, because the functions call each other and it seems like if while is used you need one connection for it seperated.
MySQL Syntax is okay, as phpmyadmin is telling me.
Everything works exept Adgroups_AD/Adgroups_Performance
Any Ideas?
It seems like that i even need to commit select query's in python.
That fixed the issue. dang.
I've read many threads about sqlite database and how to update with wal and checkpoint but I really do not understand despite all the information on Internet.
I merge two sqlite databases on a Desktop computer with a Python script but when I put the new file (store.data) back to the folder in Xcode and replace the old one the app crashes at running (error 259). I think this happens because the original wal/shm file does not recognize the new database (which has now new information/columns/rows) but I cannot figure out how I can create new wal/shm from this file. Or should I modify those ones at the same time I merge databases?
EDIT:
it works fine when I execute the PRAGMA wal_checkpoint(RESTART) in sqlite browser app... I replace the old files in my Xcode folder but it only works if I make a new rebuild and not if I just open it in the simulator... This will not cause a problem on a real device since I will not rebuild the app but just launch it? Is there a way to get round of it?
I currently have a tediously long process for creating new instances of a CMS we make.
I plan to script as much of the process as I can, using Python.
The first step is creating a database.
Currently it is a manual process where I will create an empty database "MyNewSite" and then select restore from backup and restore it from the "master" db file. Before the restore I change the data and log paths accordingly (so they dont overwrite the master).
Is there any way to automate this? I'm not really sure where to begin so any help would be appreciated.
The CMS you make should have a deployment script. All your development process should update upgrade scripts, never touch the database directly. Database updates should be deployed through source code (upgrade scripts) and version control: Version Control and your Database.
I've added new models and pushed to our staging server, run syncdb to create their tables, and it locks up. It gets as far as 'Create table photos_photousertag' and postgres output shows the notice for creation of 'photos_photousertag_id_seq', but otherwise i get nothing on either said. I can't ctrl+c the syncdb process and I have no indication of what route to take from here. Has anyone else ran into this?
We use postgres, and while we've not run into this particular issue, there are some steps you may find helpful in debugging:
a. What version of postgres and psycopg2 are you using? For that matter, what version of django?
b. Try running the syncdb command with the "--verbosity=2" option to show all output.
c. Find the SQL that django is generating by running the "manage.py sql " command. Run the CREATE TABLE statements for your new models in the postgres shell and see what develops.
d. Turn the error logging, statement logging, and server status logging on postgres way up to see if you can catch any particular messages.
In the past, we've usually found that either option b or option c points out the problem.
I just experienced this as well, and it turned out to just be a plain old lock on that particular table, unrelated to Django. Once that cleared the sync went through just fine.
Try querying the table that the sync is getting stuck on and make sure that's working correctly first.
Strange here too, but simply restarting the PostgreSQL service (or server) solved it. I'd tried manually pasting the table creation code in psql too, but that wasn't solving it either (well, no way it could if it was a lock thing) - so I just used the restart:
systemctl restart postgresql.service
that's on my Suse box.
Am not sure whether reloading the service/server might lift existing table locks too?