PostgreSQL multi user application - python

I want to know that if multi-users try to access same database for insert or retrieve data via my python program, do they all need to install PostgreSQL in their computers? How this process works?

If the database is located on another server, then no, clients don't have to install postgresql. They will need to install a postgresql adapter, like psycopg, so that python can communicate with the database, and most applications choose to use some type of ORM, like sqlalchemy, on top of the database adapter to make communication with the database more object-oriented and pythonic.

If you use psycopg2, it already comes with lipq DLL, the library used to communicate with PostgreSQL through TCP.
Actually, psycopg2 is a wrapper for libpq:
http://initd.org/psycopg/docs/
Therefore, you won't need to install PostgreSQL server binaries in the client workstations.

Related

Is there a way to connect Python to an external sqlite3 database

I haven't been able to find any documentation regarding whether it's possible to access SQLITE3 (using Python) when the SQLITE database is hosted externally:
I have my SQLITE3 database hosted on my VPS (alongside some other stuff that doesn't really matter) - rather than having it as a local file with my Python program.
Therefore, is it possible for me to connect to the SQLITE database which is hosted on my VPS, or will the SQLITE DB have to be hosted locally for me to be able to do this?
The reason I want it to be accessible from my VPS is because I want to be able to run the program on multiple computers and them all have the same access to the database- if this isn't possible, are there any other options which would allow me to do this?
If you want to have a database server with external, possibly remote, applications interacting a client-server protocol switch to PostgreSQL, MariaDB, etc.
see: How to connect to SQLite3 database server?

How to connect to SQLite3 database in python remotely

I use SQLite3 in python because my school computers don't allow us to install anything to python so I used the pre installed SQLite3 module.
I'm working on a program whose back end relies on an SQLite3 database, however the databases are created and stored on their computer.
Is it possible for me to "Host" an SQLite3 database on let's say a server and allow my script to access them remotely (my script could edit the database from my school computer)?
By the way, I'm using python 3.X
EDIT
i made a database api that runs in python 3, its called TaliffDb
to install type pip3 install TaliffDB in your terminal. im working on a documentation, but please do comment if you have any questions
Write an API on the remote server, yes. This could be hosted by a web framework of your choice.
You won't get a direct network connection to a file

using mysql instead of sqlite3

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.

python SQLITE database connection wrapper

I have the following setting:
a restricted system that contains SQLite database and is able to use python.
a usual PC-system.
My aim is to write an application (preferable JAVA) for the PC-system to connect to the SQLite databse on the remote System to read, alter, etc. tables. Unfortunaetly I'm not able to install a Webserver on the remote system because system restrictions deny this intention. So i have been asking myself if it is possible to connect to the database anyway?! I thought of something like a Python connection wrapper, that redirects all database calls. Hope someone can give me a hint for solving this problem.
SQLite is not "db server" but "db file". You can't connect remotly to it because it is not server (you had to write own server). You can copy file with data to another computer and use it but you get two seperated databases. If you can share (in network) folder with that file you can use it on all computers - but there can be problem with concurent writing. SQLite is not designed to work with many users at the same time.

In python, is there a simple way to connect to a mysql database that doesn't require root access?

I'm writing a script to parse some text files, and insert the data that they contain into a mysql database. I don't have root access on the server that this script will run on. I've been looking at mysql-python, but it requires a bunch of dependencies that I don't have available. Is there a simpler way to do this?
I would recommend the MySQL Python Connector, a MySQL DB-API adapter that does not use the C client library but rather reimplements the MySQL protocol completely in pure Python (compatible with Python 2.5 to 2.7, as well a 3.1).
To install C-coded extensions to Python you generally need root access (though the server you're using might have arranged things differently, that's not all that likely). But with a pure Python solution you can simply upload the modules in question (e.g. those from the Connector I recommend) just as you're uploading those you write yourself, which (if you of course do have a valid userid and password for that MySQL database!-) might solve it for you.

Categories

Resources