+ 8

[SOLVED] Making python MySQL supported executable file?

I want to ask all python experts on sololearn that how can I make a python file(MySQL/database connected) executable that can work on any system which doesn't have MySQL installed. I have tried using pyinstaller but it only makes for python scripts not MySQL supported. I want to create a database supported python executable file. So, please help me.

11th May 2020, 12:07 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
17 Antworten
+ 6
That really depends how much security you need. Sqlite does not have any built-in encryption. You can read about its security features here: https://www.sqlite.org/security.html Sqlite3 databases are simple files that can be opened and manipulated with a text editor or a database management software like DBeaver. On the other hand, what kind of security features are you relying on with mysql, when the database is installed on the client machine? If you just want to hide or encrypt the data in the file system, you could use sqlite with in-memory mode, and make an encrypted backup on the filesystem whenever you want to save. Not sure if this could be feasible, depends on how much data you have. Read the section about backup: https://pynative.com/JUMP_LINK__&&__python__&&__JUMP_LINK-sqlite/ And about Cryptography: https://hackernoon.com/how-to-encrypt-and-decrypt-data-in-python-53193yhj
12th May 2020, 5:28 AM
Tibor Santa
Tibor Santa - avatar
+ 10
You can't. You would need to run the mysql server yourself. And its not a good idea to allow connections outside localhost. Use sqlite which doesn't require a server. Or just use text or json files
11th May 2020, 2:38 PM
Toni Isotalo
Toni Isotalo - avatar
+ 4
You could also have the database hosted in the cloud, and let the client connect to it remotely. If this is not an option then use sqlite3 instead of mysql. It is built into standard python, no need for installing anything.
12th May 2020, 4:30 AM
Tibor Santa
Tibor Santa - avatar
+ 4
#Try this... import sqlite3 #To perform sql in python conn=sqlite3.connect("academy.db") #use sqlite3.connect() to connect with database if exist otherwise it creates cur=conn.cursor() #cursor() is used to perform sql commands cur.execute("""create table student(id int primary key, name varchar(20), level int, gender varchar(1));""") #execute() is used to execute the sql cur.execute("""insert into student values(1, 'coder', 15, 'M');""") #remember that you can only execute one statement in execute() cur.execute(""" insert into student values(2, 'programmer',13, 'G');""") cur.execute("""select * from student""") #After creating a table use this above statement to output result=cur.fetchall() #fetchall() is used to fetch one or more records print(*result,sep="\n") #Atlast print
13th May 2020, 8:16 AM
Jenson Y
+ 4
AKSHAY It's very secure and fast to use sqlite3 in python.
13th May 2020, 8:20 AM
Jenson Y
+ 3
I am posting this according to my knowledge.yeah i think using SQLite is secure.Only the SQLite driver is installed by default with Python. I think you have to install MySQL driver ,This is installed by default with phython.The most used package to do so is MySQLdb but it's hard to install in easy way.What i mean to say is it is a tough task Please note MySQLdb only supports Python 2. you can have MySQLdb,for windows user For Linux, may be python-mysqldb you can install MySQLdb using Macport,for mac Try to reboot.......... Once you understand how to use it,there is a need to use object relational mapping to avoid SQL manually and manipulate tables as they are phython objects Here i am giving an example of ORM i.e;SQLAlchemy.Hope this may help you.Please let me know if you have any doubts furthur
12th May 2020, 5:18 AM
Divya Peddapalyam
Divya Peddapalyam - avatar
+ 2
Toni Isotalo & Tibor Santa using sqlite is secure??
12th May 2020, 4:37 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
Thanks all of you for your answers I think I will solve my problem with your answers.
12th May 2020, 6:25 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
Thanks Lay_in_life for your help. I will use sqlite3 in my program.
13th May 2020, 10:34 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
Code Crasher Did you also have same problem or you want to know about sqlite3 module?
13th May 2020, 12:53 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
Or for the security, you could use encryption in the given language and store the encrypted data. And you could also set your DB only to allow connections from the server running the program and the computers that you trust doing this via the IP address
13th May 2020, 5:12 PM
Joshua Flynn
Joshua Flynn - avatar
+ 2
Code Crasher 👍🏻 Nice, keep it up
14th May 2020, 10:30 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
Code Crasher These are going over my head because I have just started on sql. May be these are useful in future because sometimes I can't find all content at one place. Thanks once again 🙂
14th May 2020, 2:04 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
Joshua Flynn I don't have that much knowledge about that you are talking but I will look for this in future. Thanks for your help
14th May 2020, 10:29 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar