How to deploy/store tkinter sqlite database in a server? - python

I have a login interface, I used tkinter and sqlite3 as database, everything works fine, in my data base stored locally in my PC I've created an username and password which i use to login, I would like to know if there is a way to store only my sqlite.db in a cloud or some server and i can still be able to login with my tkinter interface in any computer using my databese in the cloud.
this is what im using to connect my sqlite database locally and works smootly.
conn = sqlite3.connect('login_file.db')
c = conn.cursor()
user = entry_usuario.get()
contra = entry_contrasena.get()
c.execute('SELECT * FROM superusuario WHERE usuario = ? AND password = ?', (user, contra))
if c.fetchall():
messagebox.showinfo(title='login correcto', message='usuario y contraseƱa correctos')
else:
messagebox.showerror(tittle=None, message='ContraseƱa Incorrecta')
c.close()
Psdt: I was trying to use firebase authentication to link with my tkinter login interface, but i wasnt succesful with it (i dont know how to replace it), maybe i should use another server?, any advise please let me know, thanks in advance have a good day

sqlite is a file based database, with no in built network server. So your application needs to access it as a file in a known location.
The only way to do this without a server side function is to host it on a remote network drive - and mount it on your pc; but to do that you leave your data exposed since sqlite data bases aren't password protected in any form - anyone could download the database and open it.
To protect it you would need to implement a network server (maybe on an AWS server - or similar) which gave protected access and exposed the data as a REST API, or even better, don't use sqlite if you want a remote database.

Related

can you use connectorx with SQL SERVER?

I am trying to reduce the loading times to extract a database from SQL SERVER. I have read a lot about this library but no matter how hard I have tried I have not been able to connect, can someone tell me if this is possible or guide me to configure it, thanks.
try using pyodbc config
per this discussion, at least some support has been added
I used sqlalchemy's urlib to make urls: and since url objects do not have a split() method, I cast to string.
connection_url = str(sqlalchemy.engine.URL.create("mssql",database=database, host=servername,
username=username,
password=password,
query = {'driver':'SQL Server'}))
I then used connectorx.read_sql(connection_url, 'select * from sys.databases') to validate the connection worked.
It worked for my system's sql server authentication database connections but failed to login for Windows Domain Authentication.

Accessing an Azure Database for MySQL Single Server from outside Azure

Moving this question from DevOps Stack Exchange where it got only 5 views in 2 days:
I would like to query an Azure Database for MySQL Single Server.
I normally interact with this database using a universal database tool (dBeaver) installed onto an Azure VM. Now I would like to interact with this database using Python from outside Azure. Ultimately I would like to write an API (FastAPI) allowing multiple users to connect to the database.
I ran a simple test from a Jupyter notebook, using SQLAlchemy as my ORM and specifying the pem certificate as a connection argument:
import pandas as pd
from sqlalchemy import create_engine
cnx = create_engine('mysql://XXX', connect_args={"ssl": {"ssl_ca": "mycertificate.pem"}})
I then tried reading data from a specific table (e.g. mytable):
df = pd.read_sql('SELECT * FROM mytable', cnx)
Alas I ran into the following error:
'Client with IP address 'XX.XX.XXX.XXX' is not allowed to connect to
this MySQL server'.
According to my colleagues, a way to fix this issue would be to whitelist my IP address.
While this may be an option for a couple of users with static IP addresses I am not sure whether it is a valid solution in the long run.
Is there a better way to access an Azure Database for MySQL Single Server from outside Azure?
As mentioned in comments, you need to whitelist the IP address ranges(s) in the Azure portal for your MySQL database resource. This is a well accepted and secure approach.

Connect to Snowflake via Python Connector OKTA

Anyone use the Python Connector to connect to Snowflake, specifically using https://<your_okta_account_name>.okta.com (i.e. the URL endpoint for Okta) to authenticate through native Okta.? I keep getting the error below, but I know it is the correct password/username. I am able to login fine via 'external browser" (but not through cloud9, nor do I want to continue this way)
Failed to connect to DB: appfolio.snowflakecomputing.com:443. Incorrect username or password was specified.
I have the following variables set up and I know I have correct password/username so going a little crazy , anyone here have this issue?
authenticator = 'https://company.okta.com'
user='user.name#company.com',
password= "password",
account='company'
People are having the same error (with & without MFA) but no solution was posted on snowflakes community board: https://community.snowflake.com/s/question/0D50Z00009JJKZGSA5/unable-to-connect-to-snowflake-using-aws-lambda

How to connect python to Oracle Application Express

I would like to have some help with the parameters passed under the connection string through a .py file trying connection to my Oracle Apex workspace database:
connection = cx_Oracle.connect("user", "password", "dbhost.example.com/dbinstance", encoding="UTF-8")
On the login page at "apex.oracle.com", we have to pass the following information:
Can I assume that the "user" parameter is equal to the USERNAME info, the "password" parameter is equal to the PASSWORD info and the "dbinstance" parameter is equal to the WORKSPACE info?
And what about the hostname? What is it expected as parameter? How do I find it?
Thank you very much for any support.
Those parameters are not equivalent. An APEX workspace is a logical construct that exists only within APEX; it does not correspond to a physical database instance. Username and password do not necessarily correspond to database users, as APEX is capable of multiple methods of authentication.
APEX itself runs entirely within a single physical database. An APEX instance supports multiple logical workspaces, each of which may have its own independent APEX user accounts that often (usually) do not correspond to database users at all. APEX-based apps may have entirely separate authentication methods of their own, too, and generally do not use the same users defined for the APEX workspaces.
When an APEX application does connect to a database to run, it connects as a proxy user using an otherwise unprivileged database account like APEX_PUBLIC_USER.
If you want to connect Python to APEX, you would have to connect like you would any other web app: through the URL using whatever credentials are appropriate to the user interface and then parsing the HTML output, or through an APEX/ORDS REST API (that you would have to first build and deploy).
If you want to connect to the database behind APEX, then you would need an appropriately provisioned database (not APEX) account, credentials and connectivity information provided by the database administrator.

retrieving data from rackspace database through python

I have very little knowledge of rackspace..My client has setup one server at rackspace cloud and saying that he created one database and I have to retrieve data from there , while logging into https://mycloud.rackspace.com/ , I found that server is created at
PublicNet (Internet) 166.78.105.176
and I also can access database via phpmyadmin http://"link"/phpmyadmin
But the problem is I need instance Id of that database from cloud control panel to connect to database as said in http://www.rackspace.com/knowledge_center/article/connecting-to-your-cloud-database , which I am not able to get as I am not able to see database in cloud control panel..
Please help..am I in right direction ? or I am totally in wrong path.
Any suggestions would be helpful me..

Categories

Resources