Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDB schema export doesn't work with SQLite #1157

Open
pkulev opened this issue Dec 24, 2023 · 3 comments
Open

NDB schema export doesn't work with SQLite #1157

pkulev opened this issue Dec 24, 2023 · 3 comments

Comments

@pkulev
Copy link
Contributor

pkulev commented Dec 24, 2023

I'm currently investigating another issue with NDB FDB. While reviewing https://docs.pyroute2.org/ndb_debug.html#rtnl-events to gather additional debug information, I encountered this 😅

In [103]: NDB().schema.export()
2023.12.24 19:26:01.114 ( events.py:0084): D: init
2023.12.24 19:26:01.115 ( source.py:0431): D: starting the source
2023.12.24 19:26:01.116 ( events.py:0084): D: init
2023.12.24 19:26:01.116 ( source.py:0431): D: starting the source
2023.12.24 19:26:01.117 ( events.py:0084): D: connecting
2023.12.24 19:26:01.117 ( events.py:0084): D: loading
2023.12.24 19:26:01.118 ( events.py:0084): D: connecting
2023.12.24 19:26:01.122 ( events.py:0084): D: loading
2023.12.24 19:26:01.125 ( events.py:0084): D: running
2023.12.24 19:26:01.224 ( events.py:0084): D: running

table interfaces
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/local/lib/python3.9/site-packages/pyroute2/ndb/schema.py:515 in execute                     │
│                                                                                                  │
│    512 │   │   │   #                                                                             │513 │   │   │   for _ in range(MAX_ATTEMPTS):                                                 │
│    514 │   │   │   │   try:                                                                      │
│ ❱  515 │   │   │   │   │   self.cursor.execute(*argv, **kwarg)                                   │
│    516 │   │   │   │   │   break                                                                 │
│    517 │   │   │   │   except (sqlite3.InterfaceError, sqlite3.OperationalError) as e:           │
│    518 │   │   │   │   │   self.log.debug('%s' % e)                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140057114806016 and this is thread id 140058015954752.
@svinota
Copy link
Owner

svinota commented Jan 10, 2024

Two interfaces are available:

# sqlite backup
ndb.backup("file_name.db")

# same but without the shortcut
ndb.task_manager.db_back("file_name.db")

# the old export method
ndb.task_manager.db_export()

I should update the docs probably...

@svinota
Copy link
Owner

svinota commented Jan 10, 2024

Shortly speaking all the published ndb.schema methods (with @publish decorator) are available as ndb.task_manager.db_*

@svinota
Copy link
Owner

svinota commented Jan 10, 2024

Sorry for delays, I was a bit off track the last year, but coming back now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants