Framework v Core
Django mysqlclient安装和使用详解 这篇文章主要介绍了Django mysqlclient安装和使用详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧. MacOS使用django安装mysqlclient遇到的问题(mysqlclient 1.3.3 or newer is required) 最近需要使用django搭建一个网站,使用的数据库是mysql。 mac电脑里面已经安装好了mysql-5.7-community。 之前使用的python.
The Editor libraries are available for both .NET Framework and .NET Core and present an identical API for both platforms. The information in the Getting started, Validation and other sections of the .NET manual for Editor applies to both platforms. Only the installation is a little different due to the database connection required by each.
This documentation guides you through the installation and basic use of the Editor libraries on your .NET Core environment. The end result is a portable software package that can be run on Windows, Mac or Linux.
Demo package installation
This installation is a simple four step process which the documentation below will guide you though.
Download
Mac Pip3 Install Mysqlclient
To download the Editor .NET Core package, open the Editor download page and select the Editor .NET Core package. If you already have a DataTables account the download will start immediately. If you don't have a DataTables account you will be asked to create one to start a trial.
When the download completes, unzip the files. If you are a Visual Studio user, open the project file. If you prefer the command line, edit the files described below in your favourite Editor.
Examples SQL
We now need to load your database with the tables and data required for the Editor examples. The .NET libraries work with a number of different databases, each of which requires its own SQL. The following links contain the SQL needed for each of the supported databases:
Select the appropriate file for your database and then run the SQL contained within on your database access portal (SQL Server Management Studio, CLI, phpMyAdmin or pgAdmin3 for example). The demo SQL will create new tables and enter data into them. Note that they will overwrite any conflicting table names - installing into a new database is recommended, and also, as is good practice, ensure that you have backed up your database.
Database connection
The next step is to set up the database connection so the Editor libraries can interact with the database server. This is done through the Database
class in the DataTables
namespace, which is a database abstraction layer, so it can interface with any of the above database types.
Mac Python Mysqlclient
The database connection for the demo package is configured in the Properties/launchSettings.json
file. There are DBTYPE
and DBCONNECTION
environment variables available which should be set to provide your database connection (note that there are two instances for these variables, one for IIS Express and one for a generic web-server, e.g. Nginx, replace both with your connection detaiils.
DBTYPE
- This defines the database type you are connecting to and can be one of:azure
- Microsoft Azuremysql
- MySQLpostgres
- PostgreSQLoracle
- Oraclesqlite
- SQLitesqlserver
- SQL Serversqlserverce
- SQL Server CE (for local file databases)
DBCONNECTION
- This is the database connection string to connect to the SQL server. The exact format of the connection string depends upon the server being used, but typically it includes the server host name / address, user name and password. The Connection Strings web-site can be useful if you aren't sure of what connection string to use for your server.
Running the examples
That's all the set up that is needed to run the examples! To actually run them, now press F5 or select the Start debugging option from the Debug menu in Visual Studio.
NuGet
The Editor server-side libraries for .NET are available on NuGet for easy inclusion in your project without needing to build or locally reference the DataTables-Editor-Server.dll yourself. To install via NuGet search in Visual Studio's NuGet explorer for 'DataTables-Editor-Server' and install. If you prefer to install on the command line use:
Database connection
Program
The database connection for .NET Core differs a little from .NET Framework. In .NET Framework the database drivers that are available to a program are automatically available system wide (through machine.config
). This is not the case in .NET Core and you must register the database driver you want to use - typically in Program.cs
or Startup.cs
. The registration is done using the DbProviderFactories.RegisterFactory
method:
SQL Server
MySQL
PostgreSQL
SQLite
Controllers
From this point on, the connection to the database is the same as for .NET Framework (since the data provider has been registered). In each controller a Database
class instant is initialised (note that the examples make use of the using
statement to ensure that the connection is closed when no longer required - you could call db.Close()
manually if you prefer):
A connection string. Note that the values DbType
can take is defined in the list of strings above. If using this method, you may wish to store the connection string in a global configuration like the demo examples (shown above).
An existing DbConnection
.
DbConnectionStringBuilder
.
Next steps
With the examples running, the next step is to start experimenting with the examples and understanding how the Editor C# code operates. Beyond that, you can start to include Editor in your own applications (Web API / MVC)!