Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

receiving error on executing DB command

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    receiving error on executing DB command

    Hello, I am working on a strategy and testing on playback, I haven't had this error come up before and I don't understand what it means. The full error copied is as follows:

    Error on executing DB command: code = Constraint (19), message = System.Data.SQLite.SQLiteException (0x800027AF): constraint failed FOREIGN KEY constraint failed at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt) at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt) at System.Data.SQLite.SQLiteDataReader.NextResult() at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCo mmand cmd, CommandBehavior behave) at System.Data.SQLite.SQLiteCommand.ExecuteReader(Com mandBehavior behavior) at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery(C ommandBehavior behavior) at NinjaTrader.NinjaScript.StrategyBase.DbAdd() at NinjaTrader.Cbi.DB.DBThread()

    I don't think I've added anything to the code that would be accessing a database I haven't already been using. I have 1 minute dataseries and tick dataseries added for NQ that has already been working fine before now.

    #2
    Hello somethingcomplex,

    Thank you for your post.

    The Playback101 account that trades are submitted to when connected to the Playback connection is based on the properties of the Sim101 account which is stored in the NinjaTrader.sqlite database file. First, I suggest resetting your Sim101 account and then testing for this error. To manage, edit, or reset your Sim101 account, do the following:
    • Disconnect from the Playback connection
    • Go to the Control Center > Accounts window
    • Right-click on the Sim101 account > select 'Edit Account'
    • In this window, you may change the Initial Cash Size for your Sim101 account, as well as add other features such as Commissions and Risk Templates
    • To apply the changes, click on the 'reset' button at the bottom of the window. You may need to restart the platform for these changes to take full effect.
    • Reconnect to Playback and test
    If the error persists, then the error might be caused by another item in your database. If that is the case, you can try renaming your database. You may rename your database to resolve this item using the following steps:
    • Shutdown NinjaTrader, and navigate to the Windows File Explorer (Windows Key + E)
    • Go to the Documents/NinjaTrader 8/db folder
    • Right-click on "NinjaTrader.sqlite" and rename it to "NinjaTrader OLD.sqlite"
    • When you restart NinjaTrader, a fresh database file will automatically be created by the software.
    • Unfortunately, the following items stored in the old database will be lost - custom Trading Hours templates, custom Instruments/Instrument Lists, historical trade execution data, and saved Strategy Analyzer backtest results
    To prevent running into situations where you can potentially lose important data, we advise running regular backups via the built-in Backup feature in NinjaTrader.

    Please let us know if we can be of further assistance.


    Comment


      #3
      When you say custom instruments will be lost, will the strategy I'm working on be gone? I can export it as a ninja script add on and then reload it with the new database correct? Also the link to the backup page takes me to the ninjatrader website but says page not found. Also I was wondering, I don't get the database error when I run it with the previous stops and targets I was using, only when I run the new stuff I'm testing. Would that still be congruent with a database error of this sort?

      Comment


        #4
        Originally posted by somethingcomplex View Post
        When you say custom instruments will be lost, will the strategy I'm working on be gone? I can export it as a ninja script add on and then reload it with the new database correct? Also the link to the backup page takes me to the ninjatrader website but says page not found. Also I was wondering, I don't get the database error when I run it with the previous stops and targets I was using, only when I run the new stuff I'm testing. Would that still be congruent with a database error of this sort?
        No; the strategy will not be lost. Only custom instruments that have been added to the Control Center > Tools > Instruments window would be lost:


        More information about the backup and restore functions may be found in the help guide here:


        Although you have only seen this since testing new stuff, it does seem to be related to the NinjaTrader.sqlite database file. You could always test by renaming the file, and if for any reason you need to revert to your previous database file you may shut down NinjaTrader, add "NEW" to the new database file name, and remove "OLD" from the previous database file. Then, when you launch NinjaTrader again it will be using the previous file (although this could cause the errors and unexpected behavior to return).

        Thank you for your time and patience.

        Comment


          #5
          Hello Emily,

          at first I got same error (large error code) like somethingcomplex​,

          With sim account reset was the same so I rename the DB. With new DB file it seems better (less and short error code) but I cannot fix it.

          Could you tell me something more about? I see that it show category connection, PlayBack reset, Price feed disconnection ...

          Is a DB internal problem or could be something in my strategy code? Finally the strategy seems work fine.

          Could be for the playback speed execution? (I have a W11Pro, 12th Gen Intel(R) Core(TM) i9-12900H 2.50 GHz, 32Gb RAM).

          Let me know ... Many thanks.
          Best regards.

          Click image for larger version

Name:	imagen.png
Views:	554
Size:	738.5 KB
ID:	1328227

          Comment


            #6
            Hello ClauTrade,

            This would likely be something corrupted in the database.

            After renaming the database file so a new one is generated, does the error still occur?

            In the screenshot you've provided, I am seeing that after NinjaTrader was restarted the error has not re-occurred.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            116 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            61 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            40 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            43 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            82 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X