I have been trying to save some data into txt files, but now I have decided to use a database to store these values. But I can't seem to find how can this be achieved, I've read through some tutorials but they all seem to be for online app building.
Are there any modules that can be used to create MySQL database on my hard disk , are there any alternatives ?
Is it necessary to make a server even if i'm using the database on the same computer for some local stuff ?
If you only need a local database, you can use the builtin sqlite3-database.
Related
I have a python program in which I am downloading user data and updating a table. I only need to store the most current updates for each user.
Is there a simple (maybe No SQL, key/value) DB that would be good for maintaining a single table like this? I would just store it in a dict in python but I need persistence.
I am running this on an AWS EC2 linux server. I know there are AWS options (Dynamo) but I thought a local DB might be easier.
Thanks
Look into python stdblib dbm module, fallback to an embedded okvs.
I'm a noobie to Django and I'm almost at the stage of deploying a web server.
I was just having some doubts with Django's database. Currently I'm using the default sqlite3 database to store all the user models as well as the info models. I'm thinking of using AWS to deploy my web sever.
So when I get to that stage, should I continue with sqlite or should I switch to AWS's database or something like Firebase. If I continue with sqlite, where and how exactly will the information be stored? And what if I switch to something like PostgreSQL, where will the information be stored and will it be secure/fast (even if I manage to get thousands of users)?
Thanks so much, this question might be really basic but I'm super confused.
sqlite is a flat file database, it uses an exposed file in your project to save your data, this is fine in local environment, but when deploying you need to consider that the server and the database are in the same machine and using the same disk. that means if you accidentally remove the machine -and its disk space- used to serve the application, then the database itself will be deleted with all records.
Plus you will face problems if you tried to scale your servers, that is every server will have his own copy of the database and syncing all those files will be huge headache.
If your data is not that important then you can keep using sqlite, but if you are expecting high traffic and complex db structure, then I would recommend you consider a db engine like Mysql or maybe look up the databases offered by amazon here:
https://aws.amazon.com/products/databases/
For django, you will need to change the adapter when using a different db like mysql, sqlite or anything else.
https://docs.djangoproject.com/en/3.0/ref/databases/
I developed an application in C, using MySQL. Now I wanted to migrate to Oracle, and don't want to make so many changes in code as well, like connecting to database and etc. 'liboramysql' a MySQL Client Library Driver for Oracle Database which is very useful in this case.
But a part of my entire code is written in Python as well, for which I need a similar lib or something similar to it. Is there any way to do this?
Say I have a database of recipes that I have online, and I want to use this database in a program, but I want to store the information from the database internally to the program and only have to connect to the online database when I want to update, however I don't want my end-users to have to have a database(MySql, MSSQL, etc..) installed to their machine. What would be the best way to efficiently do this?
sqlite is the most common way to use databases without a database server.
I am looking for a small database that can be "embedded" into my Python application without running a separate server, as one can do with SQLite or Metakit. I don't need an SQL database, in fact storing free-form data like Python dictionaries or JSON is preferable.
The other requirement is that to be able to run an instance of the database on a server, and have instances of my application (clients) sync the database with the server (two-way), similar to what CouchDB replication can do.
Is there a database that will do this?
From what you describe, it sounds like you could get by using pickle and FTP.
If you don't need an SQL database, what's wrong with CouchDB? You can spawn a local process to serve the DB, and you could easily write a server wrapper to allow only access from your app. I'm not sure about the access story, but I believe the latest Ubuntu uses CouchDB for synchronizeable user-level data.
Seems like the perfect job for CouchDB: 2 way sync is incredibly easy, schema-less JSON documents are the native format. If you're using python, couchdb-python is a great way to work with CouchDB.
Do you need clients to work offline and then resync when they reconnect to the network? I don't know if MongoDB can handle the offline client scenario, but if the client is online all the time, MongoDB might be a good solution too. It has pretty goode python support. Still a separate process, but perhaps easier to get running on Windows than CouchDB.
BerkeleyDB might be another option to check out, and it's lightweight enough. easy_install bsddb3 if you need a Python interface.
HSQLDB does this, but unfortunately it's Java rather than Python.
Firebird SQL might be closer to what you want, since it does seem to have a Python interface.