How can I get the schema or row names of a table in soci?

user7537486

I am trying to accomplish this, and I know how to do it indirectly...if I can get the schema of a table.

How can I do this using soci?

I have tried:

std::string i;
soci::statement st = (mSql->prepare <<
               "show create table tab;",
               soci::into(i));
st.execute();
while (st.fetch())
{   
         std::cout << i <<'\n';
}

but only "tab" gets printed.

I also tried this, from the Soci documentation in GitHub:

soci::column_info ci;
soci::statement st = (mSql->prepare_column_descriptions(table_name), into(ci));

st.execute();
while (st.fetch())
{
    // ci fields describe each column in turn
}

but was told that column_info is not a member of soci.

user7537486

I found the following code here

soci::row v;
soci::statement st = (mSql->prepare << "SELECT * FROM tab", into(v));
st.execute(true);  /* with data exchange */
unsigned int num_fields = v.size();
std::cout << "fields: " << num_fields << std::endl;
num_fields = (num_fields <= 9) ? num_fields : 9;
unsigned long num_rows = (unsigned long)st.get_affected_rows();
std::cout << "rows: " << num_rows << std::endl;
for (size_t i = 0; i < num_fields; ++i) {
    const soci::column_properties &props = v.get_properties(i);
    std::cout << props.get_name() << '\t';
}
std::cout << std::endl;

The last things printed are the correct names of the columns.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How can I get column names from a table in SQL Server?

From Dev

How can I get the background color of an HTML table's row?

From Dev

I have a subset matrix extracted from a data frame, how can I get the corresponding row names?

From Dev

How can I sort a data.frame (table) based on another object's row.names

From Dev

How do I get schema / column names from parquet file?

From Dev

How can I get the current Datomic schema?

From Dev

How can I get table records passing table name and column names at runtime in hibernate?

From Dev

How do i get the row values instead of the row names

From Dev

How can I get temporal table schema information from DACFx API?

From Dev

How can I get temporal table schema information from DACFx API?

From Dev

How can I arrange this code so I can get different entry from database for each table row

From Dev

How can I get a list of table names from an existing sqlite database using SQLite.NET?

From Dev

How can I get list of all table names in .lua script using Lua C API?

From Dev

How can i get a list of total sums based off names in a table and their points (from column)?

From Dev

How can i use a lookup table to get a row from a parent table using parameter in django

From Dev

How do I obtain all the row names in a Cassandra table, efficiently?

From Dev

How do I format row.names of an R table?

From Dev

How to get the schema name when I have table name - Oracle

From Dev

How can I get row's index from a table in SQL Server?

From Dev

How can I get the row id of the a table in the sqlite database when an Item is clicked in the listview

From Dev

How can I get the row and column number when the user clicks in a particular column table in jquery

From Dev

How can I get Html table row to default to no height when div within it has visibility:none

From Dev

How can I get the row count of a table that is in a different database from where the query is run?

From Dev

How can i get gridview row count

From Dev

How can I get the "row" from indexPathsForSelectedRows?

From Dev

How can I get all fields with same schema using find()?

From Dev

How can I get the full schema definition of a Mongoose collection?

From Dev

how can i melt a data.table with concatenated column names

From Dev

How can I create a table with names of directories and subdirectories in R?

Related Related

  1. 1

    How can I get column names from a table in SQL Server?

  2. 2

    How can I get the background color of an HTML table's row?

  3. 3

    I have a subset matrix extracted from a data frame, how can I get the corresponding row names?

  4. 4

    How can I sort a data.frame (table) based on another object's row.names

  5. 5

    How do I get schema / column names from parquet file?

  6. 6

    How can I get the current Datomic schema?

  7. 7

    How can I get table records passing table name and column names at runtime in hibernate?

  8. 8

    How do i get the row values instead of the row names

  9. 9

    How can I get temporal table schema information from DACFx API?

  10. 10

    How can I get temporal table schema information from DACFx API?

  11. 11

    How can I arrange this code so I can get different entry from database for each table row

  12. 12

    How can I get a list of table names from an existing sqlite database using SQLite.NET?

  13. 13

    How can I get list of all table names in .lua script using Lua C API?

  14. 14

    How can i get a list of total sums based off names in a table and their points (from column)?

  15. 15

    How can i use a lookup table to get a row from a parent table using parameter in django

  16. 16

    How do I obtain all the row names in a Cassandra table, efficiently?

  17. 17

    How do I format row.names of an R table?

  18. 18

    How to get the schema name when I have table name - Oracle

  19. 19

    How can I get row's index from a table in SQL Server?

  20. 20

    How can I get the row id of the a table in the sqlite database when an Item is clicked in the listview

  21. 21

    How can I get the row and column number when the user clicks in a particular column table in jquery

  22. 22

    How can I get Html table row to default to no height when div within it has visibility:none

  23. 23

    How can I get the row count of a table that is in a different database from where the query is run?

  24. 24

    How can i get gridview row count

  25. 25

    How can I get the "row" from indexPathsForSelectedRows?

  26. 26

    How can I get all fields with same schema using find()?

  27. 27

    How can I get the full schema definition of a Mongoose collection?

  28. 28

    how can i melt a data.table with concatenated column names

  29. 29

    How can I create a table with names of directories and subdirectories in R?

HotTag

Archive