Closed AnuragReddy2000 closed 4 years ago
Sorry to bother you, what was the solution, did you found it?
Hi!, It's been sometime since I have worked on that project. I don't quite remember the exact cause of the problem, but I know that I figured it out very shortly after posting this question. That's why I closed it on the same day. The bug was in the oncreate function. I remember dabbling around with the syntax etc..... Sorry I couldn't be of better help.
Any one can help?
db.execute(''' CREATE TABLE $table ( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL, ) ''');
format should be written as
db.execute('''
CREATE TABLE $table (
$columnKey TEXT NOT NULL PRIMARY KEY,
$columnText TEXT NOT NULL,
$columnDate TEXT NOT NULL,
$columnTime TEXT NOT NULL,
$columnSilent TEXT NOT NULL,
$columnRepeat TEXT NOT NULL,)''');
this solves the issue
$columnRepeat TEXT NOT NULL, <=== from that line just make it without comma to be $columnRepeat TEXT NOT NULL
remove the comma for the syntax to work, Happy coding
db.execute(''' CREATE TABLE $table ( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL, ) ''');
format should be written as db.execute(''' CREATE TABLE $table ( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL,)''');
this solves the issue
Thank you so much for this
Thanks for letting me know, and I wish you the best of luck with your coding.
On Thu, Mar 17, 2022 at 10:07 AM Qaasim Muhammad Akorede < @.***> wrote:
db.execute(''' CREATE TABLE $table ( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL, ) ''');
format should be written as db.execute(''' CREATE TABLE $table ( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL,)''');
this solves the issue
Thank you so much for this
— Reply to this email directly, view it on GitHub https://github.com/Jaguar-dart/jaguar_orm/issues/185#issuecomment-1070389661, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARYIWWLEICUJ5NAEN7TEJS3VALK3RANCNFSM4MK5MESQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
FOR FLUTTER DEVELOPERS --
You need to remove space from table name and "(" and you have to remove the ending ",".
This give an error- db.execute(''' CREATE TABLE $table ( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL, ) ''');
This solves the error- db.execute(''' CREATE TABLE $table( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL) ''');
Thank you so much for this.. You saved me one more day
Good job , that works
FOR FLUTTER DEVELOPERS --
You need to remove space from table name and "(" and you have to remove the ending ",".
This give an error- db.execute(''' CREATE TABLE $table ( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL, ) ''');
This solves the error- db.execute(''' CREATE TABLE $table( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL) ''');
Yes it is working now after i remove the space and extra ',' ..... Thanks a lot.
This is the error I get when i try to insert a row into the table :
[ +94 ms] E/SQLiteLog(22990): (1) near ")": syntax error [ +17 ms] I/flutter (22990): error DatabaseException(near ")": syntax error (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE Events ( [ +3 ms] I/flutter (22990): Id TEXT NOT NULL PRIMARY KEY, [ +13 ms] I/flutter (22990): Text TEXT NOT NULL, [ +1 ms] I/flutter (22990): Date TEXT NOT NULL, [ +2 ms] I/flutter (22990): Time TEXT NOT NULL, [ +2 ms] I/flutter (22990): Silent TEXT NOT NULL, [ +9 ms] I/flutter (22990): Repeat TEXT NOT NULL, [ +5 ms] I/flutter (22990): )) sql ' CREATE TABLE Events ( [ +4 ms] I/flutter (22990): Id TEXT NOT NULL PRIMARY KEY, [ +8 ms] I/flutter (22990): Text TEXT NOT NULL, [ +1 ms] I/flutter (22990): Date TEXT NOT NULL, [ +13 ms] I/flutter (22990): Time TEXT NOT NULL, [ +2 ms] I/flutter (22990): Silent TEXT NOT NULL, [ +1 ms] I/flutter (22990): Repeat TEXT NOT NULL, [ +2 ms] I/flutter (22990): ) [ +1 ms] I/flutter (22990): ' args []} during open, closing... [ +2 ms] E/flutter (22990): [ERROR:flutter/shell/common/shell.cc(213)] Dart Error: Unhandled exception: [ +9 ms] E/flutter (22990): DatabaseException(near ")": syntax error (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE Events ( [ +11 ms] E/flutter (22990): Id TEXT NOT NULL PRIMARY KEY, [ +9 ms] E/flutter (22990): Text TEXT NOT NULL, [ +12 ms] E/flutter (22990): Date TEXT NOT NULL, [ +1 ms] E/flutter (22990): Time TEXT NOT NULL, [ +2 ms] E/flutter (22990): Silent TEXT NOT NULL, [ +12 ms] E/flutter (22990): Repeat TEXT NOT NULL, [ +10 ms] E/flutter (22990): )) sql ' CREATE TABLE Events ( [ +5 ms] E/flutter (22990): Id TEXT NOT NULL PRIMARY KEY, [ +1 ms] E/flutter (22990): Text TEXT NOT NULL, [ +2 ms] E/flutter (22990): Date TEXT NOT NULL, [ +7 ms] E/flutter (22990): Time TEXT NOT NULL, [ +7 ms] E/flutter (22990): Silent TEXT NOT NULL, [ +2 ms] E/flutter (22990): Repeat TEXT NOT NULL, [ +12 ms] E/flutter (22990): ) [ +1 ms] E/flutter (22990): ' args []} [ +2 ms] E/flutter (22990): #0 wrapDatabaseException (package:sqflite/src/exception_impl.dart:12:7) [ +13 ms] E/flutter (22990):
[ +19 ms] E/flutter (22990): #1 SqfliteDatabaseFactoryImpl.wrapDatabaseException
(package:sqflite/src/factory_impl.dart:30:7)
[ +116 ms] E/flutter (22990): #2 SqfliteDatabaseMixin.safeInvokeMethod
(package:sqflite_common/src/database_mixin.dart:208:15)
[ +116 ms] E/flutter (22990): #3 SqfliteDatabaseMixin.invokeExecute
(package:sqflite_common/src/database_mixin.dart:370:12)
[ +179 ms] E/flutter (22990): #4 SqfliteDatabaseMixin.txnExecute.
(package:sqflite_common/src/database_mixin.dart:362:14)
[ +1 ms] E/flutter (22990): #5 SqfliteDatabaseMixin.txnSynchronized
(package:sqflite_common/src/database_mixin.dart:312:26)
[ +7 ms] E/flutter (22990): #6 SqfliteDatabaseMixin.txnWriteSynchronized
(package:sqflite_common/src/database_mixin.dart:345:7)
[ +2 ms] E/flutter (22990): #7 SqfliteDatabaseMixin.txnExecute
(package:sqflite_common/src/database_mixin.dart:351:12)
[ +1 ms] E/flutter (22990): #8 SqfliteDatabaseExecutorMixin.execute
(package:sqflite_common/src/database_mixin.dart:41:15)
[ ] E/flutter (22990): #9 DBManager._onCreate (package:virtual_event_manager/dataBase/DBManager.dart:40:14)
(package:sqflite_common/src/database_mixin.dart:701:37)
[ ] E/flutter (22990):
[ ] E/flutter (22990): #11 SqfliteDatabaseMixin.doOpen.
(package:sqflite_common/src/database_mixin.dart)
[ ] E/flutter (22990): #12 SqfliteDatabaseMixin._runTransaction
(package:sqflite_common/src/database_mixin.dart:475:28)
[ ] E/flutter (22990):
[ ] E/flutter (22990): #13 SqfliteDatabaseMixin.transaction.
(package:sqflite_common/src/database_mixin.dart:492:14)
[ +6 ms] E/flutter (22990): #14 SqfliteDatabaseMixin.txnSynchronized
(package:sqflite_common/src/database_mixin.dart:312:26)
[ +1 ms] E/flutter (22990): #15 SqfliteDatabaseMixin.txnWriteSynchronized
(package:sqflite_common/src/database_mixin.dart:345:7)
[ ] E/flutter (22990): #16 SqfliteDatabaseMixin.transaction
(package:sqflite_common/src/database_mixin.dart:491:12)
[ ] E/flutter (22990): #17 SqfliteDatabaseMixin.doOpen (package:sqflite_common/src/database_mixin.dart:692:15)[ ] E/flutter (22990):
[ ] E/flutter (22990): #18 SqfliteDatabaseOpenHelper.openDatabase
(package:sqflite_common/src/database.dart:46:22)
[ ] E/flutter (22990): #19 SqfliteDatabaseFactoryMixin.openDatabase.
(package:sqflite_common/src/factory_mixin.dart:104:43)
[ ] E/flutter (22990):
[ ] E/flutter (22990): #20 SqfliteDatabaseFactoryMixin.openDatabase.
(package:sqflite_common/src/factory_mixin.dart)
[ +1 ms] E/flutter (22990): #21 ReentrantLock.synchronized..
(package:synchronized/src/reentrant_lock.dart:35:24)
[ +2 ms] E/flutter (22990): #22 _rootRun (dart:async/zone.dart:1184:13)
[ +8 ms] E/flutter (22990): #23 _CustomZone.run (dart:async/zone.dart:1077:19)
[ ] E/flutter (22990): #24 _runZoned (dart:async/zone.dart:1619:10)
[ ] E/flutter (22990): #25 runZoned (dart:async/zone.dart:1539:10)
[ ] E/flutter (22990): #26 ReentrantLock.synchronized.
(package:synchronized/src/reentrant_lock.dart:34:24)
[ ] E/flutter (22990): #27 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:32:26)
[ ] E/flutter (22990): #28 ReentrantLock.synchronized (package:synchronized/src/reentrant_lock.dart:30:17)
[ +2 ms] E/flutter (22990): #32 DBManager.database (package:virtual_event_manager/dataBase/DBManager.dart:27:17)
[ ] E/flutter (22990): #10 SqfliteDatabaseMixin.doOpen.
[ ] E/flutter (22990): #29 SqfliteDatabaseFactoryMixin.openDatabase (package:sqflite_common/src/factory_mixin.dart:71:17) [ ] E/flutter (22990): #30 openDatabase (package:sqflite/sqflite.dart:152:26) [ ] E/flutter (22990): #31 DBManager._initDatabase (package:virtual_event_manager/dataBase/DBManager.dart:34:18) [ +8 ms] E/flutter (22990):
[ +1 ms] E/flutter (22990): #33 DBQueries._insert (package:virtual_event_manager/dataBase/DBQueries.dart:21:37)
[ +1 ms] E/flutter (22990): #34 DBQueries.insertRow (packa
`import 'package:sqflite/sqflite.dart'; import 'package:path/path.dart' show join;
class DBManager{ static final _databaseName = "EventManager.db"; static final _databaseVersion = 1;
DBManager._(); static final DBManager instance = DBManager.(); factory DBManager() => _instance;
static final table = 'Events';
static final columnKey = 'Id'; static final columnText = 'Text'; static final columnDate = 'Date'; static final columnTime = 'Time'; static final columnSilent = 'Silent'; static final columnRepeat = 'Repeat';
static Database _db; Future get database async {
if (_db != null) return _db;
}
_initDatabase() async { String databasesPath = await getDatabasesPath(); String path = join(databasesPath, _databaseName); return await openDatabase(path, version: _databaseVersion, onCreate: _onCreate); }
Future _onCreate(Database db, int version) async { await db.execute(''' CREATE TABLE $table ( $columnKey TEXT NOT NULL PRIMARY KEY, $columnText TEXT NOT NULL, $columnDate TEXT NOT NULL, $columnTime TEXT NOT NULL, $columnSilent TEXT NOT NULL, $columnRepeat TEXT NOT NULL, ) '''); } }
import 'package:sqflite/sqflite.dart'; import 'DBManager.dart'; import 'package:uuid/uuid.dart';
class DBQueries {
void insertRow(List inp) async {
var uuid = Uuid();
Map<String, dynamic> row = {
DBManager.columnKey : uuid.v4().toString(),
DBManager.columnText : inp[0],
DBManager.columnDate : inp[1],
DBManager.columnTime : inp[2],
DBManager.columnSilent : inp[3],
DBManager.columnRepeat : inp[4],
};
_insert(row);
}
Future _insert(Map<String,dynamic> row) async {
Database db = await DBManager().database;
int id = await db.insert(DBManager.table, row);
return id;
}
Future deleteRow(String key) async {
Database db = await DBManager().database;
int id = await db.delete(DBManager.table,where: '$DBManager.columnId = ?', whereArgs: [key]);
return id;
}
/Future
/void getEvents(String date) async { Database db = await DBManager().database; List