Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I generate XML Data from the SQLite Database?

Tags:

In such DBMS as Oracle or PostgreSQL there are functions for generating XML Data from the database: http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb13gen.htm or http://www.postgresql.org/docs/current/static/functions-xml.html#AEN15086

My question are there something similar in SQLite database? May be there are some additional tools, libraries or even standard tools for this purpose?

like image 440
JohnFerrito Avatar asked Jul 28 '13 12:07

JohnFerrito


People also ask

How can a XML file be created from a database?

Here we are going to create an XML file from Database. Make an SQL connection to the Database and execute the sql and store the data in a Datset. Call Dataset's WriteXml() method and pass the file name as argument. You have to pass necessary database connection information to connection string.

Can you convert SQL to XML?

With SQL Server Management Studio, you can save your SQL database as CSV and then you can convert the database files to XML, PDF or other formats as you like.

Why is SQLite not good for production?

Long answer: It is said you can't use SQLite in production because it doesn't support concurrency (no more than one user can be writing to the database at the same time) and it can't scale.


1 Answers

If you are using C#.NET there can be two ways for it.

  1. You can get the data into datasets and use the .WriteXml() method to write into the xml file.

    var sqc = new SqlConnection(ConfigurationManager.ConnectionStrings["AddsConnectionString"].ConnectionString);       
    
    sqc.Open();
    
    var q = "select * from adv";
    
    var sqd = new SqlDataAdapter(q, sqc);
    
    var ds = new DataSet();
    
    sqd.Fill(ds,"adv");
    
    ds.WriteXml("d:/data.xml");
    

Do not forget to include System.Xml

  1. OR else you can use Linq.
like image 168
Tushar Sharma Avatar answered Sep 28 '22 09:09

Tushar Sharma