Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Connecting MySQL database in Dart
Ayoub Ali
Ayoub Ali

Posted on

     

Connecting MySQL database in Dart

Connecting MySQL database in dart is really easy. First you have to create a dart project.
Create Project

Plugin

mysql1: ^0.20.0

This plugin has some issues, but it's something that we have right now to work with.

Description

Create a function add host which in this case is localhost and port which your MySQL port is running.
In case of Windows you need XAMPP and in case of macOS see the documentation.
db is database name you created inside MySQL. Or You can add it by your own choice if you don't want to choose the existing one.

Function

Writing queries inside function

Queries

Note

When you are using this plugin, and you're adding the db name in connection setting if you are adding the same name it will give you error even if your data is getting insert inside the database of existing table but one thing you should remember that db name should be different because db represent the database name and table is that will be generated inside the database. One thing also that you should not write insert query again and again to insert multiple data. Just use the same query and change data inside, it will insert on top of it with different ID of course. And at the end, don't forget to close it.

SourceCode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

AI Engineer | Programmer | Security Researcher
  • Work
    Freelancer - Looking for Opportunities
  • Joined

More fromAyoub Ali

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp