Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8252549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:35:29+00:00 2026-06-08T00:35:29+00:00

Is it possible to attach a named SQLite3 :memory: database using the C API?

  • 0

Is it possible to attach a named SQLite3 :memory: database using the C API? There is of course sqlite3_open, but how do I set the name to be used in queries? Also, I could attach it by executing the ATTACH DATABASE statement, but then how do I get hold of its DB pointer?

Background:

I am using virtual tables to drive a SQLite interface to a set of external files. I am using SQLite mainly to get access to decent SQL querying and existing drivers for e.g. Python. I have defined a function open_myfiles which currently creates all the virtual tables based on the files in a given directory. The application just has to do SELECT open_myfiles('/path/to/tables') and the database is populated with the correct virtual tables.

However, I am attempting an improvement. Currently, the virtual tables are persisted to the current database and it is difficult to load multiple directories. I think that a better approach would be to attach each directory as a separate, named, :memory: database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:35:30+00:00Added an answer on June 8, 2026 at 12:35 am

    After some research, I found out that there is no clear connection between a C api database ptr and an attached database. I had to modify my initial approach, and here is how I solved it in case anyone else stumbles upon this.

    Instead of registering the virtual table module on extension load, I register a virtual table module for each invocation of the open_myfiles function. In addition to registering the module, this function also executes ATTACH DATABASE ':memory:' AS 'mymod' to put the virtual tables in their respective namespace (CREATE VIRTUAL TABLE works with qualified names as well, it turns out).

    All in all, it works very well. I hope this helps someone else!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to attach a file using mailto: redirect in javascript? Something like
Is it possible to attach filters (I'm not sure about the name of this)
is possible to make own help message or attach own event on help option
Is it possible to create a EBS volume from and attach it to the
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Question: Is it possible to use a variable as your table name without having
I found a bunch of possible duplicates around this but none really seemed to
Is it possible to send GPS coordinates, a name and hyperlink to a kind
I'm inserting a number of instances of a particular object to a database using
Is it possible to attach the windows debugger in VS2010 to a process from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.