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

Wish: data export as SQL Insert command #532

Open
the-Arioch opened this issue Sep 6, 2024 · 7 comments
Open

Wish: data export as SQL Insert command #532

the-Arioch opened this issue Sep 6, 2024 · 7 comments

Comments

@the-Arioch
Copy link

i wish the data could be put into the same SQL script as the "create Database" statement

https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb208861

@joyfullservice
Copy link
Owner

The above link appears to be broken... Could you expand a bit more on what you are wanting to accomplish?

@the-Arioch
Copy link
Author

sorry, i was just looking if Access SQL has a native multi-row insert (or bulk insert, or batch insert), like ANSI SQL and MS SQL do.

It seems, Access does not have, albeigt there is a common workaround using select/union/select

@the-Arioch
Copy link
Author

i just want a meethod to convert an MDB blob into GIT-able script. The CREATE TABLE parts work nice, but the data part does not

@joyfullservice
Copy link
Owner

i just want a meethod to convert an MDB blob into GIT-able script. The CREATE TABLE parts work nice, but the data part does not

Thanks, this is helpful background. When you say MDB blob, are you referring to a field with binary data like OLE attachments? Also, how did the XML format work with your particular use case? XML is typically able to produce a reliable output that works nicely in GIT, in my experience.

@the-Arioch
Copy link
Author

the-Arioch commented Sep 6, 2024 via email

@joyfullservice
Copy link
Owner

Thank you again for the additional background. Yes, you are exactly right that Access doesn't have a good conversion to VCS friendly source files out of the box, that's precisely why this add-in was developed. The aim of this tool is to produce a comprehensive set of source files that can build an exact copy of your database at any point in the development lifecycle. I don't even keep my binary mdb/accdb files in version control any more. I just keep the source files since that is where I manage the changes, and from which I build the binaries.

The add-in does support exporting table data, and the best format for this is XML. If you export source files from a database, and have all the tables set to export their data as XML, you should be able to build this database from source and have both the structure and data fully reconstructed from the source files.

As far as automating the build pipeline, this is something that several of us have an interest in developing, but I don't know that anyone is quite at that point yet. (Personally, I am looking at the direction of a GitLab runner on a Windows machine that kicks off a build tool to build a database from source using this add-in.)

In your particular use case, I can why you were looking for automatically generated insert statements for the data. It would be handy to pass those over to SQL to load the data. In Access you might start running into issues if you try to build a giant union query. (It may throw errors when adding 50 or more rows at a time, since each row adds another union.)

One approach you could take is to tap into the AfterExport hook with your own VBA code in a standard module to export your tables as CSV or some other easily readable format. Then in your build pipeline, you could loop through the rows in your CSV file and dynamically build the SQL statements to insert the data a row at a time. (Assuming you are using another tool for the main build pipeline.)

Hope that helps!

@the-Arioch
Copy link
Author

the-Arioch commented Sep 6, 2024 via email

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

No branches or pull requests

2 participants