Web2py Error" <class 'sqlite3.OperationalError'> no such table: application - sqlite

When I try to add a new record to Web2py Database I get this error. I've moved the repository from a different machine but all of my files are same.
My previous database DAL connection parameters are as follow:
from gluon.contrib.appconfig import AppConfig
myconf = AppConfig(reload=True)
if not request.env.web2py_runtime_gae:
db = DAL(myconf.get('db.'+myconf.get('db.mode')+'_uri'),
pool_size=myconf.get('db.pool_size'),
migrate=myconf.get('db.migrate'),
migrate_enabled=myconf.get('db.migrate_enabled'),
#fake_migrate_all=myconf.get('db.fake_migrate_all'),
fake_migrate_all=True,
check_reserved=['all'])
else:
db = DAL('google:datastore+ndb')
session.connect(request, response, db=db)
It was giving me user_auth not found error so I changed it into this by following the official docs:
from gluon.contrib.appconfig import AppConfig
myconf = AppConfig(reload=True)
if not request.env.web2py_runtime_gae:
db = DAL('sqlite://storage.sqlite', pool_size=1, check_reserved=['all'], migrate=False, fake_migrate_all=True)
else:
db = DAL('google:datastore+ndb')
It shows all the table in /database and in "Database_Administration" console I try to add a new record I get the error below.
Web2py Error" <class 'sqlite3.OperationalError'> no such table: application
There is no table in my app named "application" so it has to be related to app. Please advise.

Go to your database folder in "applications/yourappname/databases". Remove all the tables and then recreate tables. You must had copied it from somewhere and couldn't get all the tables loaded. Set migrate=True and fake_migrate_all=false. Then rerun server and go to your app in web2py server panel. Select "Edit" and go to "database administration" under "Models" on the admin panel. You will get all the tables recreated on your own machine. If this is not the case that you've copied from some other source....still do the following by deleting all the tables. You will surely get it up and running.

You have created a completely new database, but by setting fake_migrate_all=True, you have made web2py think all the tables have been created even though they never were. Instead, you should initially leave migrate=True (the default), and do not set fake_migrate_all. In that case, web2py will create the tables upon the first request (after that, you can disable migrations until you need to make another change).

Related

How to solve room data integrity error due to identityHash mismatch?

Issue:
Whenever I make changes to the database or the model, I get the following Room data integrity error:
My understanding is that I shouldn't need to increase the version number since I am using .fallbackToDestructiveMigration().
Background:
I using DB Browser for SQLite (v3.12.0) to make changes to the database.
I frequently make changes to my app/database, which is still in development. So, I am using a .fallbackToDestructiveMigration() (see codelab example).
File: RoomDB.java
#Database(entities =
{Note.class, Label.class, Join_ScheduleLabel.class, Schedule.class},
version = 1)
#TypeConverters(DataConverters.class)
public abstract class RoomDB extends androidx.room.RoomDatabase {
public static final String DATABASE_NAME = "vk_prepop.sqlite";
private static RoomDB INSTANCE;
public static RoomDB getInstance(final Context context) {
if (INSTANCE == null) {
synchronized (RoomDB.class) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(
context.getApplicationContext(),
RoomDB.class,
DATABASE_NAME)
// Source: https://developer.android.com/training/data-storage/room/prepopulate
.createFromAsset(DATABASE_NAME)
// Todo: Remove Destructive Migration
// Wipes and rebuilds instead of migrating if no Migration object.
.fallbackToDestructiveMigration()
.build();
}
}
}
return INSTANCE;
}
public abstract RoomDao getRoomDao();
}
Troubleshooting Steps Taken:
Verifying the entities of the RoomDB.java file match the models and database.
Going into the App Info and tapping "Clear data" (see SO answer).
Uninstalling the app.
Making setting android:allowBackup="false" in the manifest (see SO answer).
Possible Solution:
In live-love's answer he says there may be an identityHash mismatch, but I am not sure how to resolve this using DB Browser for SQLite.
My understanding is that I shouldn't need to increase the version number since I am using .fallbackToDestructiveMigration().
The fallBackToDestructiveMigration only runs if a migration is required and there is no Migration covering the migration.
In your situation the issue is that you have included the room_master_table in the pre-packaged database and hence the identity_hash columns is available for comparison (which would be incorrect if changes were made to the schema that affected how room generates the identity_hash from the schema).
By including the room_master_table you are introducing an unnecessary complexity.
If you omit this table from the pre-packaged database, then it will be created and populated, with the appropriate identity_hash when it is created from the asset (i.e. when the database doesn't exist). As such you then only have to make the appropriate changes to the asset (the pre-packaged database), delete the current database (e.g. uninstall the App or clear the Apps data) and then run the App.
live-love's answer states that there may be an identityHash mismatch. Indeed this was the case. Here is how I resolved the issue using DB Browser for SQLite (v3.12.0).
Step 1: In Android Studio's project panel choose the "Project" view:
Step 2: Then double-click on the json file for your schema:
Step 3: Copy the identityHash in this json file:
Step 4: Open your database in DB Browser for SQLite. Click the "Browse Data" tab. Then from the drop-down menu choose "room_master_table".
Step 5: Compare the identifyHash from the json file in Android Studio to the identityHash in DB Browser for SQLite. If the hashes are different, this can be the cause of you Room data integrity error.
Step 6: So, paste the identityHash from the Android Studio's json file into the identityHash cell in the DB Browser for SQLite.
Step 7: Then press Ctrl+Shift+S to save the database.
Step 8: Click "Close Database".
Step 9: In your app on your phone or emulator go to "App Info" -> "Storage" -> "Clear data".
Step 10: Then in Android Studio press "Run app".
Problem solved... at least for me. If these steps did not help, please review these additional troubleshooting steps.

The path specified by "c:\Data\imoltp_mod1" is not in a valid directory

I am using Sql Server InMemory OLTP for Asp.Net application to store session data in Sql Server using this link
After that i found one error like need to create file group for the database which i used for InMemory OLTP. I was able to create the file group for my existing database. After that need to add file, For that i have tried below Query:
ALTER DATABASE imoltp ADD FILE (
name='imoltp_mod1', filename='c:\data\imoltp_mod1')
TO FILEGROUP imoltp_mod;
But when i run above query i am getting below error:
Msg 5121, Level 16, State 2, Line 1
The path specified by "c:\Data\imoltp_mod1" is not in a valid directory.
Msg 5009, Level 16, State 14, Line 1
One or more files listed in the statement could not be found or could not be initialized.
in this path i created "Data" folder, Or even tried to change the drive from C to D but still getting the same error.
I have also created new database as per this link provided solution. But stil stuck in same query.
I have here few question related to session store in DB.
When i provided DB name in session membership provider related connnectionstring, Will it create table dynamically, If yes then what could be the name of table?
Please suggest.
I also had this error. Then I realized that the c:\data\ folder has to be created on the server and not my own developer machine.

what version of mysql are datasources using?

I have a calculated table that uses a join statement SQL query as its data source. good. Works fine.
But then I'm trying to add in the use of :Parameters and my attempts to create a default if it equals null are not working.
I tried this (In the onLoad client script):
if (app.datasources.Relations.query.parameters.x== null){
console.log("No xfound,using >");
app.datasources.Relations.query.parameters.x= ">";}
It works, but not on the initial load (it appears to apply AFTER the first load).
So I decided to try and bake it into the sql statement that makes the table like this, but all three of these iterations failed with "check your version of mysql" errors.
AND b.CSI_Code REGEXP select if(:x= null, "<",:x)
AND b.CSI_Code REGEXP select if(:x== null, "<",:x)
AND b.CSI_Code REGEXP select if(:x=== null, "<",:x)
I've got a workaround going where I set my parameters to the APP onload rather than the datasource onload,but ultimately I think it would be cleaner if I could get the SQL if nul set to default (">") part working.
If you have access to the Google Cloud Platform where your database is hosted, it lists the database version in the instance information (see picture). Per the FAQ, the options are currently MySQL 5.5, 5.6, or 5.7. If you click into the instance, and go to the Databases tab, each app has its own database with a name like "Wc7cVzeGEvbPjxj4". To confirm which database your app uses, the name should be listed in your Google App Maker app under (Your app in the developer GUI) > Settings Cog Icon > Database > Database Key.

Meteor minimongo insert method not working

I was following the meteor tutorial from meteortips and I got to the part where you create a collection in the browser's console. Creating the collection works, but it doesn't let me insert anything into it.(PlayersList = new Meteor.Collection('players');)
Please see below:
PlayersList.insert({ name: 'Alex', score: 42 });
"rpPamgZEZM9opCzHz"
debug.js:41 insert failed: Method not found
What's weirder is that I even get back the hash as if the insert worked.
Typing PlayersList.find().fetch(); returns an empty array :(
I'm using the latest version of Meteor on Windows 8.1 with MongoDB version 2.6
If anybody could help me, I would be very thankful :)
You have defined the collection PlayersList = new Meteor.Collection('players'); on the client but it has not been defined on the server.
If you have something like if(Meteor.isClient) {..} (or in the /client) directory the code won't run on the server. Make sure you also place a PlayersList = new Meteor.Collection('players'); in the if(Meteor.isServer) (or the /server) directory.
The best thing to do is place it outside both in the root directory so it runs on both the client and server.
When you insert the document on the client the message is transmitted to the the server & it tries to insert it into the database. The collection isn't defined on the server side so it rejects it with the message method not found.

Restoring a database into a different instance of tridion

I have got most of the way but there seems to be a permissions issue somewhere:
Before the restore everything is working fine in my target environment - target has a server login account TCMDBUser which is mapped to my tridion_cm database user TCMDBUser
My source tridion_cm database has user TCMDBUser_DEV.
After restoring the source .bak into my target TCMDBUser_DEV is orphaned.
I edit the TRUSTEES table to correct MTSUser and my admin log accounts for my target environment and run the following to fix up my orphaned database user:
sp_change_users_login #Action='update_one',
#UserNamePattern='TCMDBUser_DEV',
#LoginName='TCMDBUser'
GO
I can log back in to Tridion explorer and see the expected list of publications and can walk through the tree structure but when I come to a folder which should contain items I see nothing with error:
and the corresponding event log error is:
Unable to get list of SDL Tridion Content Manager items.
DESCRIPTION
Error Code:
0x80040000 (-2147221504)
Call stack:
System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String)
System.Data.SqlClient.SqlDataReader.GetOrdinal(String)
System.Data.SqlClient.SqlDataReader.get_Item(String)
Tridion.ContentManager.Data.AdoNet.DatabaseUtilities.ConvertToFieldDictionary(IDataRecord,IDictionary`2)
Tridion.ContentManager.Data.AdoNet.IdentifiableObjectDataMapper.Read(TcmUri,IDataRecord,IDictionary`2)
Tridion.ContentManager.Data.AdoNet.ContentManagement.OrganizationalItemDataMapper.GetListItemsPost(IDataReader,TcmUri,OrganizationalItemItemsFilterData)
Tridion.ContentManager.Data.AdoNet.ContentManagement.OrganizationalItemDataMapper.Tridion.ContentManager.Data.ContentManagement.IOrganizationalItemDataMapper.GetListItems(TcmUri,OrganizationalItemItemsFilterData)
Tridion.ContentManager.ContentManagement.OrganizationalItem.GetListItemsData(OrganizationalItemItemsFilter)
Tridion.ContentManager.ContentManagement.OrganizationalItem.GetListItemsStream(OrganizationalItemItemsFilter)
Tridion.ContentManager.BLFacade.ContentManagement.OrganizationalItemFacade.GetListItemsXml(UserContext,String,ListFilter,ListColumnFilter)
Tridion.ContentManager.BLFacade.ContentManagement.OrganizationalItemFacade.GetListData(UserContext,String,EnumListKind,ListColumnFilter,String)
Folder.GetListItems
You will need to delete/drop the TCMDBUser_DEV form the DB and then create a new one with the same name and password (or reattach it to your cm DB). That should fix your problem.
I normally use the delete method with MS SQL server. I believe this occurs due to the ownership status that the TCMDBUser has on the database Schema.
When complete your TCMDBUser user should have the following permissions on your Tridion_CM database
Like Chris mentioned, I always drop the user from the database and then assign the existing TCMDBUser in SQL Server the rights to the restored database. You can drop the user with the following command (on the restored database):
EXEC sp_dropuser TCMDBUser
Then through the SQL Server - Security - Logins, you request the properties of your TCMDBUser and in the User Mapping add the following database roles: db_datareader, db_datawriter and db_ddladmin.
That's what I've always done in the past and works for me, not sure if its all required, but worth a try I guess
Try creating new user TCMDBUser in the database and run the following command
EXEC sp_change_users_login 'Update_One', 'TCMDBUser', 'TCMDBUser'

Resources