Dan Alexander
Dan Alexander

Reputation: 2072

Run MySQL Server in Python

So I've been looking all over the internet and only found resources/tutorials on how to connect to a MySQL server but my question is, how do you host a MySQL server both on Windows & Linux?

Upvotes: 2

Views: 1116

Answers (2)

Edgar H
Edgar H

Reputation: 1518

I am not quite sure what you are asking but if the question is how to run a database for python independent of the OS, consider using sqlite.

From the link (emphasis mine)

SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file. The database file format is cross-platform - you can freely copy a database between 32-bit and 64-bit systems or between big-endian and little-endian architectures. These features make SQLite a popular choice as an Application File Format. Think of SQLite not as a replacement for Oracle but as a replacement for fopen().

So it allows you to use a database from your python code without the hassle of running a server or setting something up locally.

Note that sqlite can also be stored in-memory if you want to avoid writing to disk.

Upvotes: 2

adrpino
adrpino

Reputation: 1040

Unless you have a very specific reason to start the server from Python, I.e. you want to be able to programmatically do stuff you wouldn't do from the command line, I think the best you could do is to install an instance of Mysql server in your local machine, run it and then, you'll be able to connect to it from Python.

Bear in mind that your local installation of Mysql will be running on localhost (127.0.0.1)

Upvotes: 0

Related Questions